Page MenuHomeSoftware Heritage

D1549.id.diff
No OneTemporary

D1549.id.diff

diff --git a/swh/storage/in_memory.py b/swh/storage/in_memory.py
--- a/swh/storage/in_memory.py
+++ b/swh/storage/in_memory.py
@@ -1468,7 +1468,7 @@
item = copy.deepcopy(item)
provider = self.metadata_provider_get(item['provider_id'])
for attr in ('name', 'type', 'url'):
- item['provider_' + attr] = provider[attr]
+ item['provider_' + attr] = provider['provider_' + attr]
metadata.append(item)
return metadata
@@ -1530,9 +1530,9 @@
an identifier of the provider
"""
provider = {
- 'name': provider_name,
- 'type': provider_type,
- 'url': provider_url,
+ 'provider_name': provider_name,
+ 'provider_type': provider_type,
+ 'provider_url': provider_url,
'metadata': metadata,
}
key = self._metadata_provider_key(provider)
@@ -1563,9 +1563,7 @@
dict: same as `metadata_provider_add`;
or None if it does not exist.
"""
- key = self._metadata_provider_key({
- 'name': provider['provider_name'],
- 'url': provider['provider_url']})
+ key = self._metadata_provider_key(provider)
return self._metadata_providers.get(key)
def _origin_id(self, origin):
@@ -1610,4 +1608,4 @@
@staticmethod
def _metadata_provider_key(provider):
- return '%r %r' % (provider['name'], provider['url'])
+ return '%r %r' % (provider['provider_name'], provider['provider_url'])
diff --git a/swh/storage/tests/test_storage.py b/swh/storage/tests/test_storage.py
--- a/swh/storage/tests/test_storage.py
+++ b/swh/storage/tests/test_storage.py
@@ -3560,6 +3560,28 @@
self.assertEqual(len(metadatas_for_origin2), 1)
self.assertCountEqual(all_metadatas, expected_results)
+ def test_metadata_provider_add(self):
+ provider = {
+ 'provider_name': 'swMATH',
+ 'provider_type': 'registry',
+ 'provider_url': 'http://www.swmath.org/',
+ 'metadata': {
+ 'email': 'contact@swmath.org',
+ 'license': 'All rights reserved'
+ }
+ }
+ provider['id'] = provider_id = self.storage.metadata_provider_add(
+ **provider)
+ self.assertEqual(
+ provider,
+ self.storage.metadata_provider_get_by({
+ 'provider_name': 'swMATH',
+ 'provider_url': 'http://www.swmath.org/'
+ }))
+ self.assertEqual(
+ provider,
+ self.storage.metadata_provider_get(provider_id))
+
def test_origin_metadata_get_by_provider_type(self):
# given
origin_id = self.storage.origin_add([self.origin])[0]['id']

File Metadata

Mime Type
text/plain
Expires
Dec 17 2024, 5:38 AM (4 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3218723

Event Timeline