diff --git a/swh/web/common/archive.py b/swh/web/common/archive.py --- a/swh/web/common/archive.py +++ b/swh/web/common/archive.py @@ -214,11 +214,18 @@ sha1 = _lookup_content_sha1(q) if not sha1: return None - lic = _first_element(idx_storage.content_fossology_license_get([sha1])) + licenses = list(idx_storage.content_fossology_license_get([sha1])) - if not lic: + if not licenses: return None - return converters.from_swh({"id": sha1, "facts": lic[sha1]}, hashess={"id"}) + license_dicts = [license.to_dict() for license in licenses] + for license_dict in license_dicts: + del license_dict["id"] + lic = { + "id": sha1, + "facts": license_dicts, + } + return converters.from_swh(lic, hashess={"id"}) def lookup_origin(origin: OriginInfo) -> OriginInfo: diff --git a/swh/web/tests/api/views/test_content.py b/swh/web/tests/api/views/test_content.py --- a/swh/web/tests/api/views/test_content.py +++ b/swh/web/tests/api/views/test_content.py @@ -167,9 +167,14 @@ url_args={"q": "sha1:%s" % content["sha1"]}, request=rv.wsgi_request, ) - expected_data = indexer_data.content_get_license(content["sha1"]) - expected_data["content_url"] = content_url - assert rv.data == expected_data + expected_data = list(indexer_data.content_get_license(content["sha1"])) + for license in expected_data: + del license["id"] + assert rv.data == { + "content_url": content_url, + "id": content["sha1"], + "facts": expected_data, + } def test_api_content_license_sha_not_found(api_client): 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 @@ -340,10 +340,9 @@ def content_get_license(self, cnt_id): cnt_id_bytes = hash_to_bytes(cnt_id) - lic = next(self.idx_storage.content_fossology_license_get([cnt_id_bytes])) - return converters.from_swh( - {"id": cnt_id_bytes, "facts": lic[cnt_id_bytes]}, hashess={"id"} - ) + licenses = self.idx_storage.content_fossology_license_get([cnt_id_bytes]) + for license in licenses: + yield converters.from_swh(license.to_dict(), hashess={"id"}) def content_add_ctags(self, cnt_id): self.ctags_indexer.run([hash_to_bytes(cnt_id)], "update-dups")