Skip to content

content_get_metadata: Adapt endpoint to return Dict[bytes, List[Dict]]

Prior to this, a shallow content was returned with all keys to None except for the sha1 key.

This now returns a dict with keys the identifier (as bytes) and the value the associated contents as list.

Clients identified using the api endpoint are [1]:

  • journal's test
  • webapp's test
  • indexer storage's rehash module (not in use right now, it was used to add a new column on contents).

They will need a slight adaptation.

  • [1]
grep -r ".content_get_metadata(" * | grep -v ".tox" | grep ".content_get_metadata("
swh-indexer/swh/indexer/rehash.py:                content_metadata = self.storage.content_get_metadata(
swh-journal/swh/journal/tests/test_replay.py:    contents = list(storage.content_get_metadata(
swh-storage/swh/storage/storage.py:    def content_get_metadata(self, content, db=None, cur=None):
swh-storage/swh/storage/tests/test_storage.py:        assert list(swh_storage.content_get_metadata([cont['sha1']])) == \
swh-storage/swh/storage/tests/test_storage.py:    def test_content_get_metadata(self, swh_storage):
swh-storage/swh/storage/tests/test_storage.py:        actual_md = list(swh_storage.content_get_metadata(
swh-storage/swh/storage/tests/test_storage.py:        gen = swh_storage.content_get_metadata([missing_cont['sha1']])
swh-storage/swh/storage/tests/test_storage.py:    def test_generate_content_get_metadata(self, swh_storage, swh_contents):
swh-storage/swh/storage/tests/test_storage.py:        actual_contents = list(swh_storage.content_get_metadata(get_sha1s))
swh-storage/swh/storage/in_memory.py:    def content_get_metadata(self, content):
swh-web/swh/web/tests/browse/views/test_content.py:    content_data = archive_data.content_get_metadata(content['sha1'])
swh-web/swh/web/tests/api/views/test_content.py:    expected_data = archive_data.content_get_metadata(content['sha1'])
swh-web/swh/web/tests/data.py:    contents_metadata = storage.content_get_metadata(contents)
swh-web/swh/web/tests/common/test_service.py:    content_metadata = archive_data.content_get_metadata(content['sha1'])
swh-web/swh/web/tests/common/test_service.py:    expected_content = archive_data.content_get_metadata(content['sha1'])
swh-web/swh/web/tests/common/test_service.py:    expected_content = archive_data.content_get_metadata(content['sha1'])
swh-web/swh/web/tests/conftest.py:    def content_get_metadata(self, cnt_id):
swh-web/swh/web/tests/conftest.py:        metadata = next(self.storage.content_get_metadata([cnt_id_bytes]))

Test Plan

tox


Migrated from D2522 (view on Phabricator)

Merge request reports

Loading