Skip to content

Commit

Permalink
mock out config load calls for unit tests with no tree
Browse files Browse the repository at this point in the history
  • Loading branch information
pmrowla authored and efiop committed Feb 14, 2021
1 parent 977949f commit b134901
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/unit/cache/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
24 changes: 23 additions & 1 deletion tests/unit/remote/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"]
Expand All @@ -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=[]
Expand Down

0 comments on commit b134901

Please sign in to comment.