mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
tests: odb: index: simplify test
For some unknown reason the mock in this test leaks into the outside tests. I wasn't able to determine why in the reasonable amount of time, so instead just simplifying it to not use mocker at all. That whole file should really be migrated to dvc-data, but that needs some time.
This commit is contained in:
@@ -8,7 +8,7 @@ from dvc_data.hashfile.db import get_index
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def index(dvc, local_remote, mocker):
|
def index(tmp_dir, dvc, local_remote):
|
||||||
odb = dvc.cloud.get_remote_odb("upstream")
|
odb = dvc.cloud.get_remote_odb("upstream")
|
||||||
return get_index(odb)
|
return get_index(odb)
|
||||||
|
|
||||||
@@ -58,23 +58,13 @@ def test_clear_on_download_err(tmp_dir, dvc, index, mocker):
|
|||||||
out = tmp_dir.dvc_gen({"dir": {"foo": "foo content"}})[0].outs[0]
|
out = tmp_dir.dvc_gen({"dir": {"foo": "foo content"}})[0].outs[0]
|
||||||
dvc.push()
|
dvc.push()
|
||||||
|
|
||||||
for _, _, hi in out.obj:
|
|
||||||
remove(dvc.cache.local.get(hi.value).path)
|
|
||||||
remove(out.fs_path)
|
|
||||||
|
|
||||||
assert list(index.hashes())
|
assert list(index.hashes())
|
||||||
|
|
||||||
def unreliable_download(_from_fs, from_info, _to_fs, to_info, **kwargs):
|
for _, _, hi in out.obj:
|
||||||
on_error = kwargs["on_error"]
|
remove(dvc.cache.local.get(hi.value).path)
|
||||||
assert on_error
|
remove(dvc.cloud.get_remote().odb.get(hi.value).path)
|
||||||
if isinstance(from_info, str):
|
remove(out.fs_path)
|
||||||
from_info = [from_info]
|
|
||||||
if isinstance(to_info, str):
|
|
||||||
to_info = [to_info]
|
|
||||||
for from_i, to_i in zip(from_info, to_info):
|
|
||||||
on_error(from_i, to_i, Exception())
|
|
||||||
|
|
||||||
mocker.patch("dvc_objects.fs.generic.transfer", unreliable_download)
|
|
||||||
with pytest.raises(DownloadError):
|
with pytest.raises(DownloadError):
|
||||||
dvc.pull()
|
dvc.pull()
|
||||||
assert not list(index.hashes())
|
assert not list(index.hashes())
|
||||||
|
|||||||
Reference in New Issue
Block a user