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

Method test

dvc/testing/remote_tests.py:17–97  ·  view source on GitHub ↗
(self, tmp_dir, dvc, remote)

Source from the content-addressed store, hash-verified

15
16class TestRemote:
17 def test(self, tmp_dir, dvc, remote):
18 (stage,) = tmp_dir.dvc_gen("foo", "foo")
19 out = stage.outs[0]
20 cache = out.cache_path
21 foo_hash = out.hash_info
22 foo_hashes = out.get_used_objs().get(None, set())
23
24 (stage_dir,) = tmp_dir.dvc_gen(
25 {
26 "data_dir": {
27 "data_sub_dir": {"data_sub": "data_sub"},
28 "data": "data",
29 "empty": "",
30 }
31 }
32 )
33
34 out_dir = stage_dir.outs[0]
35 cache_dir = out_dir.cache_path
36 dir_hash = out_dir.hash_info
37 dir_hashes = {dir_hash} | {oid for _, _, oid in out_dir.obj}
38
39 # Check status
40 status = dvc.cloud.status(foo_hashes)
41 _check_status(status, new={foo_hash})
42
43 status_dir = dvc.cloud.status(dir_hashes)
44 _check_status(status_dir, new=dir_hashes)
45
46 # Move cache and check status
47 # See issue https://github.com/treeverse/dvc/issues/4383 for details
48 backup_dir = dvc.cache.local.path + ".backup"
49 shutil.move(dvc.cache.local.path, backup_dir)
50 status = dvc.cloud.status(foo_hashes)
51 _check_status(status, missing={foo_hash})
52
53 status_dir = dvc.cloud.status(dir_hashes)
54 _check_status(status_dir, missing=dir_hashes)
55
56 # Restore original cache:
57 remove(dvc.cache.local.path)
58 shutil.move(backup_dir, dvc.cache.local.path)
59
60 # Push and check status
61 dvc.cloud.push(foo_hashes)
62 assert os.path.exists(cache)
63 assert os.path.isfile(cache)
64
65 dvc.cloud.push(dir_hashes)
66 assert os.path.isfile(cache_dir)
67
68 status = dvc.cloud.status(foo_hashes)
69 _check_status(status, ok={foo_hash})
70
71 status_dir = dvc.cloud.status(dir_hashes)
72 _check_status(status_dir, ok=dir_hashes)
73
74 # Remove and check status

Callers

nothing calls this directly

Calls 14

removeFunction · 0.90
_check_statusFunction · 0.85
openFunction · 0.85
dvc_genMethod · 0.80
moveMethod · 0.80
isfileMethod · 0.80
getMethod · 0.45
get_used_objsMethod · 0.45
statusMethod · 0.45
pushMethod · 0.45
existsMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected