Page MenuHomeSoftware Heritage

D302.id.diff
No OneTemporary

D302.id.diff

diff --git a/swh/web/common/service.py b/swh/web/common/service.py
--- a/swh/web/common/service.py
+++ b/swh/web/common/service.py
@@ -215,10 +215,12 @@
sha1 = _lookup_content_sha1(q)
if not sha1:
return None
- lang = _first_element(idx_storage.content_fossology_license_get([sha1]))
- if not lang:
+ lic = _first_element(idx_storage.content_fossology_license_get([sha1]))
+
+ if not lic:
return None
- return converters.from_swh(lang, hashess={'id'})
+ return converters.from_swh({'id': sha1, 'facts': lic[sha1]},
+ hashess={'id'})
def lookup_origin(origin):
diff --git a/swh/web/tests/common/test_service.py b/swh/web/tests/common/test_service.py
--- a/swh/web/tests/common/test_service.py
+++ b/swh/web/tests/common/test_service.py
@@ -474,13 +474,17 @@
# given
mock_idx_storage.content_fossology_license_get = MagicMock(
return_value=[{
- 'id': hash_to_bytes(
- '123caf10e9535160d90e874b45aa426de762f19f'),
- 'lang': 'python',
+ hash_to_bytes('123caf10e9535160d90e874b45aa426de762f19f'): [{
+ 'licenses': ['GPL-3.0+'],
+ 'tool': {}
+ }]
}])
expected_license = {
'id': '123caf10e9535160d90e874b45aa426de762f19f',
- 'lang': 'python',
+ 'facts': [{
+ 'licenses': ['GPL-3.0+'],
+ 'tool': {}
+ }]
}
# when
@@ -506,14 +510,19 @@
)
mock_idx_storage.content_fossology_license_get = MagicMock(
return_value=[{
- 'id': hash_to_bytes(
- '123caf10e9535160d90e874b45aa426de762f19f'),
- 'lang': 'haskell',
+ hash_to_bytes('123caf10e9535160d90e874b45aa426de762f19f'): [{
+ 'licenses': ['BSD-2-Clause'],
+ 'tool': {}
+ }]
+
}]
)
expected_license = {
'id': '123caf10e9535160d90e874b45aa426de762f19f',
- 'lang': 'haskell',
+ 'facts': [{
+ 'licenses': ['BSD-2-Clause'],
+ 'tool': {}
+ }]
}
# when

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 17, 5:50 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3223678

Event Timeline