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

Function test_output_target_remote

tests/func/test_data_cloud.py:657–709  ·  view source on GitHub ↗
(tmp_dir, dvc, make_remote)

Source from the content-addressed store, hash-verified

655
656
657def test_output_target_remote(tmp_dir, dvc, make_remote):
658 make_remote("default", default=True)
659 make_remote("for_foo", default=False)
660 make_remote("for_bar", default=False)
661
662 tmp_dir.dvc_gen("foo", "foo")
663 tmp_dir.dvc_gen("bar", "bar")
664 tmp_dir.dvc_gen("data", {"one": "one", "two": "two"})
665
666 with (tmp_dir / "foo.dvc").modify() as d:
667 d["outs"][0]["remote"] = "for_foo"
668
669 with (tmp_dir / "bar.dvc").modify() as d:
670 d["outs"][0]["remote"] = "for_bar"
671
672 # push foo and data to for_foo remote
673 dvc.push(remote="for_foo")
674
675 default = dvc.cloud.get_remote_odb("default")
676 for_foo = dvc.cloud.get_remote_odb("for_foo")
677 for_bar = dvc.cloud.get_remote_odb("for_bar")
678
679 # hashes for foo and data, but not bar
680 expected = {
681 "acbd18db4cc2f85cedef654fccc4a4d8",
682 "f97c5d29941bfb1b2fdab0874906ab82",
683 "6b18131dc289fd37006705affe961ef8.dir",
684 "b8a9f715dbb64fd5c56e7783c6820a61",
685 }
686
687 assert set(default.all()) == set()
688 assert set(for_foo.all()) == expected
689 assert set(for_bar.all()) == set()
690
691 # push everything without specifying remote
692 dvc.push()
693 assert set(default.all()) == {
694 "f97c5d29941bfb1b2fdab0874906ab82",
695 "6b18131dc289fd37006705affe961ef8.dir",
696 "b8a9f715dbb64fd5c56e7783c6820a61",
697 }
698 assert set(for_foo.all()) == expected
699 assert set(for_bar.all()) == {"37b51d194a7513e45b56f6524f2d51f2"}
700
701 clean(["foo", "bar", "data"], dvc)
702
703 # pull foo and data from for_foo remote
704 assert dvc.pull(remote="for_foo", allow_missing=True) == empty_pull | {
705 "added": ["data" + os.sep, "foo"],
706 "stats": empty_stats | {"fetched": 4, "added": 3},
707 }
708
709 assert set(dvc.cache.local.all()) == expected
710
711
712def test_pull_allow_missing(tmp_dir, dvc, local_remote):

Callers

nothing calls this directly

Calls 7

make_remoteFunction · 0.85
dvc_genMethod · 0.80
get_remote_odbMethod · 0.80
cleanFunction · 0.70
modifyMethod · 0.45
pushMethod · 0.45
pullMethod · 0.45

Tested by

no test coverage detected