self = <swh.storage.tests.test_in_memory.TestInMemoryStorage object at 0x7f001cac9630>
swh_storage = <swh.storage.in_memory.InMemoryStorage object at 0x7f001f47c6a0>
sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7f001f47c0b8>
def test_directory_entry_get_by_path(self, swh_storage, sample_data):
cont, content2 = sample_data.contents[:2]
dir1, dir2, dir3, dir4, dir5 = sample_data.directories[:5]
# given
dir_ids = [d.id for d in [dir1, dir2, dir3, dir4, dir5]]
init_missing = list(swh_storage.directory_missing(dir_ids))
assert init_missing == dir_ids
actual_result = swh_storage.directory_add([dir3, dir4])
assert actual_result == {"directory:add": 2}
expected_entries = [
{
"dir_id": dir3.id,
"name": b"foo",
"type": "file",
"target": cont.sha1_git,
"sha1": None,
"sha1_git": None,
"sha256": None,
"status": None,
"perms": from_disk.DentryPerms.content,
"length": None,
},
{
"dir_id": dir3.id,
"name": b"subdir",
"type": "dir",
"target": dir2.id,
"sha1": None,
"sha1_git": None,
"sha256": None,
"status": None,
"perms": from_disk.DentryPerms.directory,
"length": None,
},
{
"dir_id": dir3.id,
"name": b"hello",
"type": "file",
"target": content2.sha1_git,
"sha1": None,
"sha1_git": None,
"sha256": None,
"status": None,
"perms": from_disk.DentryPerms.content,
"length": None,
},
]
# when (all must be found here)
for entry, expected_entry in zip(dir3.entries, expected_entries):
actual_entry = swh_storage.directory_entry_get_by_path(
> dir3.id, [entry.name]
)
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py:909:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/storage/metrics.py:24: in d
return f(*a, **kw)
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/storage.py:579: in directory_entry_get_by_path
return self._directory_entry_get_by_path(directory, paths, b"")
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/storage.py:587: in _directory_entry_get_by_path
contents = list(self.directory_ls(directory))
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/storage.py:619: in directory_ls
yield from self._directory_ls(directory, recursive)
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/storage.py:558: in _directory_ls
contents = self._content_find_many([{"sha1_git": row.target} for row in rows])
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/storage.py:368: in _content_find_many
for row in rows:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.storage.in_memory.InMemoryStorage object at 0x7f001f47c6a0>
algo = 'sha1_git'
hashes = [b'\xd8\x1c\xc0q\x0e\xb6\xcf\x9e\xfd[\x92\n\x84S\xe1\xe0qW\xb6\xcd', b'6\xfa\xdew\x19<\xb6\xd2\xbd\x82aa\xa0\x97\x9dd\xc2\x8a\xb4\xfa', b'RV\xe8V\xa0\xa0\x89\x89f\xd6\xba\x14\xfe\xb48\x8b\x8b\x82\xd3\x02']
def _content_get_from_hashes(self, algo, hashes: List[bytes]) -> Iterable:
"""From the name of a hash algorithm and a value of that hash,
looks up the "hash -> token" secondary table (content_by_{algo})
to get tokens.
Then, looks up the main table (content) to get all contents with
that token, and filters out contents whose hash doesn't match."""
found_tokens = list(
self._cql_runner.content_get_tokens_from_single_algo(algo, hashes)
)
assert all(isinstance(token, int) for token in found_tokens)
# Query the main table ('content').
> rows = self._cql_runner.content_get_from_tokens(found_tokens)
E AttributeError: 'InMemoryCqlRunner' object has no attribute 'content_get_from_tokens'
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/storage.py:172: AttributeError
TEST RESULT
TEST RESULT
- Run At
- Sep 15 2021, 3:20 PM