Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7066375
D777.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D777.id.diff
View Options
diff --git a/swh/loader/core/tests/__init__.py b/swh/loader/core/tests/__init__.py
--- a/swh/loader/core/tests/__init__.py
+++ b/swh/loader/core/tests/__init__.py
@@ -155,7 +155,7 @@
"""
origin = self.storage.origin_get(
dict(type=origin_type, url=origin_url))
- results = self.storage.origin_metadata_get_by(origin)
+ results = self.storage.origin_metadata_get_by(origin['id'])
self.assertEqual(len(results), 1, results)
result = results[0]
self.assertEqual(result['metadata'], expected_origin_metadata)
diff --git a/swh/loader/core/tests/test_loader.py b/swh/loader/core/tests/test_loader.py
--- a/swh/loader/core/tests/test_loader.py
+++ b/swh/loader/core/tests/test_loader.py
@@ -125,22 +125,31 @@
'date': None,
},
]
- self.in_origins = [
- {
- 'type': 'git',
- 'url': 'http://example.com/',
- },
- ]
+ self.in_origin = {
+ 'type': 'git',
+ 'url': 'http://example.com/',
+ }
self.in_snapshot = {
'id': b'snap1',
'branches': {},
}
+ self.in_provider = {
+ 'provider_name': 'Test Provider',
+ 'provider_type': 'test_provider',
+ 'provider_url': 'http://example.org/metadata_provider',
+ 'metadata': {'working': True},
+ }
+ self.in_tool = {
+ 'name': 'Test Tool',
+ 'version': 'v1.2.3',
+ 'configuration': {'in_the_Matrix': 'maybe'},
+ }
- self.storage.origin_add(self.in_origins)
+ self.storage.origin_add([self.in_origin])
# used by prepare_origin_visit() when it gets called
self.loader._test_prepare_origin_visit_data = {
- 'origin': self.in_origins[0],
+ 'origin': self.in_origin,
}
def tearDown(self):
@@ -256,3 +265,27 @@
self.assertCountRevisions(1)
self.assertCountReleases(1)
self.assertCountSnapshots(1)
+
+ def test_origin_metadata(self):
+ self.loader.load()
+
+ provider_id = self.loader.send_provider(self.in_provider)
+ tool_id = self.loader.send_tool(self.in_tool)
+
+ self.loader.send_origin_metadata(
+ self.loader.origin_id, self.loader.visit_date, provider_id,
+ tool_id, {'test_metadata': 'foobar'})
+
+ self.assertOriginMetadataContains(
+ self.in_origin['type'], self.in_origin['url'],
+ {'test_metadata': 'foobar'})
+
+ with self.assertRaises(AssertionError):
+ self.assertOriginMetadataContains(
+ self.in_origin['type'], self.in_origin['url'],
+ {'test_metadata': 'foobarbaz'})
+
+ with self.assertRaises(Exception):
+ self.assertOriginMetadataContains(
+ self.in_origin['type'], self.in_origin['url'] + 'blah',
+ {'test_metadata': 'foobar'})
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Nov 5 2024, 7:01 AM (8 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3221967
Attached To
D777: Add test_origin_metadata, and fix a bug.
Event Timeline
Log In to Comment