Exemple #1
0
def test_cache_checksums(dvc):
    remote = BaseRemote(dvc, {})
    remote.path_info = PathInfo("foo")

    with mock.patch.object(
        remote, "list_cache_paths", return_value=["12/3456", "bar"]
    ):
        checksums = list(remote.cache_checksums())
        assert checksums == ["123456"]
Exemple #2
0
def test_cache_checksums_traverse(path_to_checksum, cache_checksums, dvc):
    remote = BaseRemote(dvc, {})
    remote.path_info = PathInfo("foo")

    # parallel traverse
    size = 256 / remote.JOBS * remote.LIST_OBJECT_PAGE_SIZE
    list(remote._cache_checksums_traverse(size, {0}))
    for i in range(1, 16):
        cache_checksums.assert_any_call(prefix="{:03x}".format(i),
                                        progress_callback=CallableOrNone)
    for i in range(1, 256):
        cache_checksums.assert_any_call(prefix="{:02x}".format(i),
                                        progress_callback=CallableOrNone)

    # default traverse (small remote)
    size -= 1
    cache_checksums.reset_mock()
    list(remote._cache_checksums_traverse(size - 1, {0}))
    cache_checksums.assert_called_with(prefix=None,
                                       progress_callback=CallableOrNone)