swh_storage = <swh.storage.proxies.filter.FilteringProxyStorage object at 0x7f162e5e25f8>
sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7f163734a518>
def test_filtering_proxy_storage_empty_list(swh_storage, sample_data):
swh_storage.storage = mock_storage = Mock(wraps=swh_storage.storage)
calls = 0
for object_type in swh_storage.object_types:
calls += 1
method_name = f"{object_type}_add"
method = getattr(swh_storage, method_name)
one_object = getattr(sample_data, object_type)
# Call with empty list: ensure underlying storage not called
method([])
assert method_name not in {c[0] for c in mock_storage.method_calls}
mock_storage.reset_mock()
# Call with an object: ensure underlying storage is called
> method([one_object])
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_filter.py:172:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/storage/proxies/filter.py:54: in content_add
contents_to_add = self._filter_missing_contents(content)
.tox/py3/lib/python3.7/site-packages/swh/storage/proxies/filter.py:113: in _filter_missing_contents
return set(self.storage.content_missing(missing_contents, key_hash="sha256",))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.storage.in_memory.InMemoryStorage object at 0x7f1bf93d88d0>
contents = [{'blake2s256': b"\xd5\xfe\x199We'\xe4,\xfdv\xa9EZ$2\xfe\x7fVf\x95dW}\xd9<B\x80\xe7mf\x1d", 'sha1': b'4\x972t\xcc\xefj...\xb6\xcd', 'sha256': b'\x08Ly\x9c\xd5Q\xdd\x1d\x8d\\_\x9a]Y;.\x93\x1f^6\x12.\xe5\xc7\x93\xc1\xd0\x8a\x19\x83\x9c\xc0'}]
key_hash = 'sha256'
@timed
def content_missing(
self, contents: List[Dict[str, Any]], key_hash: str = "sha1"
) -> Iterable[bytes]:
if key_hash not in DEFAULT_ALGORITHMS:
raise StorageArgumentException(
"key_hash should be one of {','.join(DEFAULT_ALGORITHMS)}"
)
contents_with_all_hashes = []
contents_with_missing_hashes = []
for content in contents:
if DEFAULT_ALGORITHMS <= set(content):
contents_with_all_hashes.append(content)
else:
contents_with_missing_hashes.append(content)
# These contents can be queried efficiently directly in the main table
> for content in self._cql_runner.content_missing_from_all_hashes(
contents_with_all_hashes
):
E AttributeError: 'InMemoryCqlRunner' object has no attribute 'content_missing_from_all_hashes'
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/storage.py:426: AttributeError
TEST RESULT
TEST RESULT
- Run At
- Oct 18 2021, 1:45 PM