Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123874
D3582.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
D3582.diff
View Options
diff --git a/swh/storage/pytest_plugin.py b/swh/storage/pytest_plugin.py
--- a/swh/storage/pytest_plugin.py
+++ b/swh/storage/pytest_plugin.py
@@ -221,27 +221,17 @@
"snapshot": [data.snapshot, data.empty_snapshot, data.complete_snapshot],
"origin": [data.origin, data.origin2],
"origin_visit": [data.origin_visit, data.origin_visit2, data.origin_visit3],
- "fetcher": [
- m.to_dict() for m in [data.metadata_fetcher, data.metadata_fetcher2]
- ],
- "authority": [
- m.to_dict() for m in [data.metadata_authority, data.metadata_authority2]
- ],
+ "fetcher": [data.metadata_fetcher, data.metadata_fetcher2],
+ "authority": [data.metadata_authority, data.metadata_authority2],
"origin_metadata": [
- m.to_dict()
- for m in [
- data.origin_metadata,
- data.origin_metadata2,
- data.origin_metadata3,
- ]
+ data.origin_metadata,
+ data.origin_metadata2,
+ data.origin_metadata3,
],
"content_metadata": [
- m.to_dict()
- for m in [
- data.content_metadata,
- data.content_metadata2,
- data.content_metadata3,
- ]
+ data.content_metadata,
+ data.content_metadata2,
+ data.content_metadata3,
],
}
@@ -276,6 +266,9 @@
"""
return {
- object_type: [convert_fn(obj) for obj in sample_data[object_type]]
+ object_type: [
+ convert_fn(obj) if isinstance(obj, dict) else obj
+ for obj in sample_data[object_type]
+ ]
for object_type, convert_fn in OBJECT_FACTORY.items()
}
diff --git a/swh/storage/tests/test_pytest_plugin.py b/swh/storage/tests/test_pytest_plugin.py
--- a/swh/storage/tests/test_pytest_plugin.py
+++ b/swh/storage/tests/test_pytest_plugin.py
@@ -31,12 +31,18 @@
]
)
for object_type, objs in sample_data.items():
- for obj in objs:
- assert isinstance(obj, dict)
+ if object_type in [
+ "fetcher",
+ "authority",
+ "origin_metadata",
+ "content_metadata",
+ ]:
+ type_ = BaseModel
+ else:
+ type_ = dict
- if sample_data_model.get(object_type):
- # metadata keys are missing because conversion is not possible yet
- assert len(objs) == len(sample_data_model[object_type])
+ for obj in objs:
+ assert isinstance(obj, type_)
def test_sample_data_model(sample_data, sample_data_model):
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 20 2024, 5:14 AM (11 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216968
Attached To
D3582: pytest_plugin: Drop unnecessary back and forth conversion
Event Timeline
Log In to Comment