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

Function test_diff_rename_file

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

Source from the content-addressed store, hash-verified

623
624@pytest.mark.parametrize("commit_last", [True, False])
625def test_diff_rename_file(tmp_dir, scm, dvc, commit_last):
626 if commit_last:
627 last_commit_msg = "commit #2"
628 a_rev = "HEAD~1"
629 else:
630 last_commit_msg = None
631 a_rev = "HEAD"
632
633 paths = tmp_dir.gen({"dir": {"file": "text1", "subdir": {"file2": "text2"}}})
634 tmp_dir.dvc_add(paths, commit="commit #1")
635 (tmp_dir / "dir" / "file").replace(tmp_dir / "dir" / "subdir" / "file3")
636
637 tmp_dir.dvc_add(paths, commit=last_commit_msg)
638 assert dvc.diff(a_rev) == {
639 "added": [],
640 "deleted": [],
641 "modified": [
642 {
643 "path": os.path.join("dir", ""),
644 "hash": {
645 "old": "cb58ee07cb01044db229e4d6121a0dfc.dir",
646 "new": "a4ac9c339aacc60b6a3152e362c319c8.dir",
647 },
648 }
649 ],
650 "renamed": [
651 {
652 "path": {
653 "old": os.path.join("dir", "file"),
654 "new": os.path.join("dir", "subdir", "file3"),
655 },
656 "hash": "cef7ccd89dacf1ced6f5ec91d759953f",
657 }
658 ],
659 "not in cache": [],
660 }
661
662
663def test_rename_multiple_files_same_hashes(tmp_dir, scm, dvc):

Callers

nothing calls this directly

Calls 5

dvc_addMethod · 0.80
joinMethod · 0.80
genMethod · 0.45
replaceMethod · 0.45
diffMethod · 0.45

Tested by

no test coverage detected