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

Function test_cloud_cli

tests/func/test_data_cloud.py:26–121  ·  view source on GitHub ↗
(tmp_dir, dvc, capsys, remote, mocker)

Source from the content-addressed store, hash-verified

24
25
26def test_cloud_cli(tmp_dir, dvc, capsys, remote, mocker): # noqa: PLR0915
27 jobs = 2
28 args = ["-v", "-j", str(jobs)]
29
30 (stage,) = tmp_dir.dvc_gen("foo", "foo")
31 cache = stage.outs[0].cache_path
32
33 (stage_dir,) = tmp_dir.dvc_gen(
34 {
35 "data_dir": {
36 "data_sub_dir": {"data_sub": "data_sub"},
37 "data": "data",
38 "empty": "",
39 }
40 }
41 )
42 assert stage_dir is not None
43 cache_dir = stage_dir.outs[0].cache_path
44
45 # FIXME check status output
46 oids_exist = mocker.spy(LocalHashFileDB, "oids_exist")
47
48 assert main(["push", *args]) == 0
49 assert capsys.readouterr().out == "5 files pushed\n"
50 assert os.path.exists(cache)
51 assert os.path.isfile(cache)
52 assert os.path.isfile(cache_dir)
53 assert oids_exist.called
54 assert all(
55 _kwargs["jobs"] == jobs for (_args, _kwargs) in oids_exist.call_args_list
56 )
57
58 dvc.cache.local.clear()
59 oids_exist.reset_mock()
60
61 assert main(["fetch", *args]) == 0
62 assert capsys.readouterr().out == "5 files fetched\n"
63 assert os.path.exists(cache)
64 assert os.path.isfile(cache)
65 assert os.path.isfile(cache_dir)
66 assert oids_exist.called
67 assert all(
68 _kwargs["jobs"] == jobs for (_args, _kwargs) in oids_exist.call_args_list
69 )
70
71 oids_exist.reset_mock()
72
73 assert main(["pull", *args]) == 0
74 assert capsys.readouterr().out == "Everything is up to date.\n"
75 assert os.path.exists(cache)
76 assert os.path.isfile(cache)
77 assert os.path.isfile(cache_dir)
78 assert os.path.isfile("foo")
79 assert os.path.isdir("data_dir")
80 assert oids_exist.called
81 assert all(
82 _kwargs["jobs"] == jobs for (_args, _kwargs) in oids_exist.call_args_list
83 )

Callers

nothing calls this directly

Calls 9

mainFunction · 0.90
openFunction · 0.85
dvc_genMethod · 0.80
isfileMethod · 0.80
isdirMethod · 0.80
moveMethod · 0.80
existsMethod · 0.45
clearMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected