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

Function test_verify_hashes

tests/func/test_data_cloud.py:195–222  ·  view source on GitHub ↗
(tmp_dir, scm, dvc, mocker, tmp_path_factory, local_remote)

Source from the content-addressed store, hash-verified

193
194
195def test_verify_hashes(tmp_dir, scm, dvc, mocker, tmp_path_factory, local_remote):
196 tmp_dir.dvc_gen({"file": "file1 content"}, commit="add file")
197 tmp_dir.dvc_gen({"dir": {"subfile": "file2 content"}}, commit="add dir")
198 dvc.push()
199
200 # remove artifacts and cache to trigger fetching
201 remove("file")
202 remove("dir")
203 dvc.cache.local.clear()
204
205 hash_spy = mocker.spy(dvc_data.hashfile.hash, "file_md5")
206
207 assert dvc.pull() == empty_pull | {
208 "added": ["dir" + os.sep, "file"],
209 "stats": empty_stats | {"fetched": 3, "added": 2},
210 }
211
212 # NOTE: 2 are for index.data_tree building
213 assert hash_spy.call_count == 3
214
215 # Removing cache will invalidate existing state entries
216 dvc.cache.local.clear()
217
218 with dvc.config.edit() as conf:
219 conf["remote"]["upstream"]["verify"] = True
220
221 assert dvc.pull() == empty_pull | {"stats": empty_stats | {"fetched": 3}}
222 assert hash_spy.call_count == 10
223
224
225# @pytest.mark.flaky(reruns=3)

Callers

nothing calls this directly

Calls 6

removeFunction · 0.90
dvc_genMethod · 0.80
editMethod · 0.80
pushMethod · 0.45
clearMethod · 0.45
pullMethod · 0.45

Tested by

no test coverage detected