From b134901e0d5c9f5768fa874009b55f600431aa97 Mon Sep 17 00:00:00 2001 From: Peter Rowlands Date: Thu, 11 Feb 2021 19:23:56 +0900 Subject: [PATCH] mock out config load calls for unit tests with no tree --- tests/unit/cache/test_local.py | 1 + tests/unit/remote/test_base.py | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/unit/cache/test_local.py b/tests/unit/cache/test_local.py index 62cb4b9e95..f6e0c81c57 100644 --- a/tests/unit/cache/test_local.py +++ b/tests/unit/cache/test_local.py @@ -15,6 +15,7 @@ def test_status_download_optimization(mocker, dvc): And the desired files to fetch are already on the local cache, Don't check the existence of the desired files on the remote cache """ + mocker.patch.object(LocalCache, "_load_config") cache = LocalCache(LocalFileSystem(dvc, {})) infos = NamedCache() diff --git a/tests/unit/remote/test_base.py b/tests/unit/remote/test_base.py index d45dcd2a99..04e782893a 100644 --- a/tests/unit/remote/test_base.py +++ b/tests/unit/remote/test_base.py @@ -36,7 +36,8 @@ def test_cmd_error(dvc): @mock.patch.object(CloudCache, "list_hashes_traverse") @mock.patch.object(CloudCache, "list_hashes_exists") -def test_hashes_exist(object_exists, traverse, dvc): +def test_hashes_exist(object_exists, traverse, dvc, mocker): + mocker.patch.object(CloudCache, "_load_config") cache = CloudCache(BaseFileSystem(dvc, {})) # remote does not support traverse @@ -95,9 +96,16 @@ def test_hashes_exist(object_exists, traverse, dvc): @mock.patch.object( CloudCache, "_path_to_hash", side_effect=lambda x: x, ) +<<<<<<< HEAD def test_list_hashes_traverse(_path_to_hash, list_hashes, dvc): cache = CloudCache(BaseFileSystem(dvc, {})) cache.fs.path_info = PathInfo("foo") +======= +def test_list_hashes_traverse(_path_to_hash, list_hashes, dvc, mocker): + mocker.patch.object(CloudCache, "_load_config") + cache = CloudCache(BaseTree(dvc, {})) + cache.tree.path_info = PathInfo("foo") +>>>>>>> mock out config load calls for unit tests with no tree # parallel traverse size = 256 / cache.fs.JOBS * cache.fs.LIST_OBJECT_PAGE_SIZE @@ -120,9 +128,16 @@ def test_list_hashes_traverse(_path_to_hash, list_hashes, dvc): ) +<<<<<<< HEAD def test_list_hashes(dvc): cache = CloudCache(BaseFileSystem(dvc, {})) cache.fs.path_info = PathInfo("foo") +======= +def test_list_hashes(dvc, mocker): + mocker.patch.object(CloudCache, "_load_config") + cache = CloudCache(BaseTree(dvc, {})) + cache.tree.path_info = PathInfo("foo") +>>>>>>> mock out config load calls for unit tests with no tree with mock.patch.object( cache, "_list_paths", return_value=["12/3456", "bar"] @@ -131,9 +146,16 @@ def test_list_hashes(dvc): assert hashes == ["123456"] +<<<<<<< HEAD def test_list_paths(dvc): cache = CloudCache(BaseFileSystem(dvc, {})) cache.fs.path_info = PathInfo("foo") +======= +def test_list_paths(dvc, mocker): + mocker.patch.object(CloudCache, "_load_config") + cache = CloudCache(BaseTree(dvc, {})) + cache.tree.path_info = PathInfo("foo") +>>>>>>> mock out config load calls for unit tests with no tree with mock.patch.object( cache.fs, "walk_files", return_value=[]