diff --git a/swh/web/tests/conftest.py b/swh/web/tests/conftest.py --- a/swh/web/tests/conftest.py +++ b/swh/web/tests/conftest.py @@ -173,8 +173,10 @@ def content_get_metadata(self, cnt_id): cnt_id_bytes = hash_to_bytes(cnt_id) - metadata = next(self.storage.content_get_metadata([cnt_id_bytes])) - return converters.from_swh(metadata, + metadata = self.storage.content_get_metadata([cnt_id_bytes]) + contents = metadata[cnt_id_bytes] + content = None if not contents else contents[0] + return converters.from_swh(content, hashess={'sha1', 'sha1_git', 'sha256', 'blake2s256'}) diff --git a/swh/web/tests/data.py b/swh/web/tests/data.py --- a/swh/web/tests/data.py +++ b/swh/web/tests/data.py @@ -229,24 +229,26 @@ directories.add(hash_to_hex(entry['target'])) # Get all checksums for each content - contents_metadata = storage.content_get_metadata(contents) + result = storage.content_get_metadata(contents) contents = [] - for content_metadata in contents_metadata: - contents.append({ - algo: hash_to_hex(content_metadata[algo]) - for algo in DEFAULT_ALGORITHMS - }) - path = content_path[content_metadata['sha1']] - cnt = next(storage.content_get([content_metadata['sha1']])) - mimetype, encoding = get_mimetype_and_encoding_for_content(cnt['data']) - content_display_data = prepare_content_for_display( - cnt['data'], mimetype, path) - contents[-1]['path'] = path - contents[-1]['mimetype'] = mimetype - contents[-1]['encoding'] = encoding - contents[-1]['hljs_language'] = content_display_data['language'] - contents[-1]['data'] = content_display_data['content_data'] - _contents[contents[-1]['sha1']] = contents[-1] + for sha1, contents_metadata in result.items(): + for content_metadata in contents_metadata: + contents.append({ + algo: hash_to_hex(content_metadata[algo]) + for algo in DEFAULT_ALGORITHMS + }) + path = content_path[sha1] + cnt = next(storage.content_get([sha1])) + mimetype, encoding = get_mimetype_and_encoding_for_content( + cnt['data']) + content_display_data = prepare_content_for_display( + cnt['data'], mimetype, path) + contents[-1]['path'] = path + contents[-1]['mimetype'] = mimetype + contents[-1]['encoding'] = encoding + contents[-1]['hljs_language'] = content_display_data['language'] + contents[-1]['data'] = content_display_data['content_data'] + _contents[contents[-1]['sha1']] = contents[-1] # Create indexer storage instance that will be shared by indexers idx_storage = get_indexer_storage('memory', {})