Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7122868
D927.id2942.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D927.id2942.diff
View Options
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
@@ -261,10 +261,15 @@
list of origin metadata as dict.
"""
- results = idx_storage.origin_intrinsic_metadata_search_fulltext(
+ matches = idx_storage.origin_intrinsic_metadata_search_fulltext(
conjunction=[fulltext], limit=limit)
- for result in results:
- result['from_revision'] = hashutil.hash_to_hex(result['from_revision'])
+ results = []
+ for match in matches:
+ match['from_revision'] = hashutil.hash_to_hex(match['from_revision'])
+ result = converters.from_origin(
+ storage.origin_get({'id': match.pop('origin_id')}))
+ result['metadata'] = match
+ results.append(result)
return results
diff --git a/swh/web/tests/api/views/test_origin.py b/swh/web/tests/api/views/test_origin.py
--- a/swh/web/tests/api/views/test_origin.py
+++ b/swh/web/tests/api/views/test_origin.py
@@ -246,10 +246,13 @@
mock_service.lookup_origin.assert_called_with({'id': '4321'})
@patch('swh.web.common.service.idx_storage')
- def test_api_origin_metadata_search(self, mock_idx_storage):
+ @patch('swh.web.common.service.storage')
+ def test_api_origin_metadata_search(self, mock_storage, mock_idx_storage):
# given
+ mock_storage.origin_get.return_value = {
+ 'id': 54974445, 'type': 'git', 'url': '/dev/null'}
mock_idx_storage.origin_intrinsic_metadata_search_fulltext \
- .return_value = [{
+ .side_effect = lambda conjunction, limit: [{
'from_revision':
b'p&\xb7\xc1\xa2\xafVR\x1e\x95\x1c\x01\xed \xf2U\xfa\x05B8',
'metadata': {'author': 'Jane Doe'},
@@ -273,28 +276,37 @@
self.assertEqual(rv.status_code, 200, rv.content)
self.assertEqual(rv['Content-Type'], 'application/json')
expected_data = [{
- 'origin_id': 54974445,
- 'metadata': {'author': 'Jane Doe'},
- 'from_revision': '7026b7c1a2af56521e951c01ed20f255fa054238',
- 'tool': {
- 'configuration': {
- 'context': ['NpmMapping', 'CodemetaMapping'],
- 'type': 'local'
- },
- 'id': 3,
- 'name': 'swh-metadata-detector',
- 'version': '0.0.1',
+ 'id': 54974445,
+ 'type': 'git',
+ 'url': '/dev/null',
+ 'metadata': {
+ 'metadata': {'author': 'Jane Doe'},
+ 'from_revision': '7026b7c1a2af56521e951c01ed20f255fa054238',
+ 'tool': {
+ 'configuration': {
+ 'context': ['NpmMapping', 'CodemetaMapping'],
+ 'type': 'local'
+ },
+ 'id': 3,
+ 'name': 'swh-metadata-detector',
+ 'version': '0.0.1',
+ }
}
}]
+ self.maxDiff = None
self.assertEqual(rv.data, expected_data)
mock_idx_storage.origin_intrinsic_metadata_search_fulltext \
.assert_called_with(conjunction=['Jane Doe'], limit=70)
@patch('swh.web.common.service.idx_storage')
- def test_api_origin_metadata_search_limit(self, mock_idx_storage):
+ @patch('swh.web.common.service.storage')
+ def test_api_origin_metadata_search_limit(self, mock_storage,
+ mock_idx_storage):
# given
+ mock_storage.origin_get.return_value = {
+ 'id': 54974445, 'type': 'git', 'url': '/dev/null'}
mock_idx_storage.origin_intrinsic_metadata_search_fulltext \
- .return_value = [{
+ .side_effect = lambda conjunction, limit: [{
'from_revision':
b'p&\xb7\xc1\xa2\xafVR\x1e\x95\x1c\x01\xed \xf2U\xfa\x05B8',
'metadata': {'author': 'Jane Doe'},
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 17 2024, 8:42 AM (4 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3223888
Attached To
D927: Make the output of search_origin_metadata a superset of that of search_metadata.
Event Timeline
Log In to Comment