Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/conftest.py
Show First 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | def content_find(self, content): | ||||
cnt_ids_bytes = {algo_hash: hash_to_bytes(content[algo_hash]) | cnt_ids_bytes = {algo_hash: hash_to_bytes(content[algo_hash]) | ||||
for algo_hash in ALGORITHMS | for algo_hash in ALGORITHMS | ||||
if content.get(algo_hash)} | if content.get(algo_hash)} | ||||
cnt = self.storage.content_find(cnt_ids_bytes) | cnt = self.storage.content_find(cnt_ids_bytes) | ||||
return converters.from_content(cnt[0]) if cnt else cnt | return converters.from_content(cnt[0]) if cnt else cnt | ||||
def content_get_metadata(self, cnt_id): | def content_get_metadata(self, cnt_id): | ||||
cnt_id_bytes = hash_to_bytes(cnt_id) | cnt_id_bytes = hash_to_bytes(cnt_id) | ||||
metadata = next(self.storage.content_get_metadata([cnt_id_bytes])) | metadata = self.storage.content_get_metadata([cnt_id_bytes]) | ||||
return converters.from_swh(metadata, | contents = metadata[cnt_id_bytes] | ||||
content = None if not contents else contents[0] | |||||
return converters.from_swh(content, | |||||
hashess={'sha1', 'sha1_git', 'sha256', | hashess={'sha1', 'sha1_git', 'sha256', | ||||
'blake2s256'}) | 'blake2s256'}) | ||||
def content_get(self, cnt_id): | def content_get(self, cnt_id): | ||||
cnt_id_bytes = hash_to_bytes(cnt_id) | cnt_id_bytes = hash_to_bytes(cnt_id) | ||||
cnt = next(self.storage.content_get([cnt_id_bytes])) | cnt = next(self.storage.content_get([cnt_id_bytes])) | ||||
return converters.from_content(cnt) | return converters.from_content(cnt) | ||||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |