From 33e764560301327a1c1824b6cf249205ab60c875 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Sun, 18 Jun 2023 17:33:06 +0300 Subject: [PATCH] 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. --- tests/func/data/db/test_index.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/tests/func/data/db/test_index.py b/tests/func/data/db/test_index.py index f87458051..6a26e38ce 100644 --- a/tests/func/data/db/test_index.py +++ b/tests/func/data/db/test_index.py @@ -8,7 +8,7 @@ from dvc_data.hashfile.db import get_index @pytest.fixture -def index(dvc, local_remote, mocker): +def index(tmp_dir, dvc, local_remote): odb = dvc.cloud.get_remote_odb("upstream") 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] dvc.push() - for _, _, hi in out.obj: - remove(dvc.cache.local.get(hi.value).path) - remove(out.fs_path) - assert list(index.hashes()) - def unreliable_download(_from_fs, from_info, _to_fs, to_info, **kwargs): - on_error = kwargs["on_error"] - assert on_error - if isinstance(from_info, str): - 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()) + for _, _, hi in out.obj: + remove(dvc.cache.local.get(hi.value).path) + remove(dvc.cloud.get_remote().odb.get(hi.value).path) + remove(out.fs_path) - mocker.patch("dvc_objects.fs.generic.transfer", unreliable_download) with pytest.raises(DownloadError): dvc.pull() assert not list(index.hashes())