Exemplo n.º 1
0
def test_list_hashes(dvc):
    odb = ObjectDB(BaseFileSystem(), None)
    odb.path_info = PathInfo("foo")

    with mock.patch.object(odb, "_list_paths", return_value=["12/3456",
                                                             "bar"]):
        hashes = list(odb.list_hashes())
        assert hashes == ["123456"]
Exemplo n.º 2
0
def test_list_hashes_traverse(_path_to_hash, list_hashes, dvc):
    odb = ObjectDB(BaseFileSystem(), None)
    odb.path_info = PathInfo("foo")

    # parallel traverse
    size = 256 / odb.fs._JOBS * odb.fs.LIST_OBJECT_PAGE_SIZE
    list(odb.list_hashes_traverse(size, {0}))
    for i in range(1, 16):
        list_hashes.assert_any_call(prefix=f"{i:03x}",
                                    progress_callback=CallableOrNone)
    for i in range(1, 256):
        list_hashes.assert_any_call(prefix=f"{i:02x}",
                                    progress_callback=CallableOrNone)

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