| 193 | |
| 194 | |
| 195 | def 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) |