MCPcopy
hub / github.com/treeverse/dvc / test_directories

Function test_directories

tests/func/test_diff.py:267–330  ·  view source on GitHub ↗
(tmp_dir, scm, dvc)

Source from the content-addressed store, hash-verified

265
266
267def test_directories(tmp_dir, scm, dvc):
268 tmp_dir.dvc_gen({"dir": {"1": "1", "2": "2"}}, commit="add a directory")
269 tmp_dir.dvc_gen({"dir": {"3": "3"}}, commit="add a file")
270 tmp_dir.dvc_gen({"dir": {"2": "two"}}, commit="modify a file")
271
272 (tmp_dir / "dir" / "2").unlink()
273 assert dvc.status() != {} # sanity check
274 dvc.add("dir")
275 scm.add(["dir.dvc"])
276 scm.commit("delete a file")
277
278 # The ":/<text>" format is a way to specify revisions by commit message:
279 # https://git-scm.com/docs/revisions
280 #
281 assert dvc.diff(":/init", ":/directory") == {
282 "added": [
283 {
284 "path": os.path.join("dir", ""),
285 "hash": "5fb6b29836c388e093ca0715c872fe2a.dir",
286 },
287 {"path": os.path.join("dir", "1"), "hash": digest("1")},
288 {"path": os.path.join("dir", "2"), "hash": digest("2")},
289 ],
290 "deleted": [],
291 "modified": [],
292 "not in cache": [],
293 "renamed": [],
294 }
295
296 assert dvc.diff(":/directory", ":/modify") == {
297 "added": [{"path": os.path.join("dir", "3"), "hash": digest("3")}],
298 "deleted": [],
299 "modified": [
300 {
301 "path": os.path.join("dir", ""),
302 "hash": {
303 "old": "5fb6b29836c388e093ca0715c872fe2a.dir",
304 "new": "9b5faf37366b3370fd98e3e60ca439c1.dir",
305 },
306 },
307 {
308 "path": os.path.join("dir", "2"),
309 "hash": {"old": digest("2"), "new": digest("two")},
310 },
311 ],
312 "not in cache": [],
313 "renamed": [],
314 }
315
316 assert dvc.diff(":/modify", ":/delete") == {
317 "added": [],
318 "deleted": [{"path": os.path.join("dir", "2"), "hash": digest("two")}],
319 "modified": [
320 {
321 "path": os.path.join("dir", ""),
322 "hash": {
323 "old": "9b5faf37366b3370fd98e3e60ca439c1.dir",
324 "new": "83ae82fb367ac9926455870773ff09e6.dir",

Callers

nothing calls this directly

Calls 8

digestFunction · 0.85
dvc_genMethod · 0.80
unlinkMethod · 0.80
joinMethod · 0.80
statusMethod · 0.45
addMethod · 0.45
commitMethod · 0.45
diffMethod · 0.45

Tested by

no test coverage detected