Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123774
D2884.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
D2884.diff
View Options
diff --git a/swh/model/model.py b/swh/model/model.py
--- a/swh/model/model.py
+++ b/swh/model/model.py
@@ -681,7 +681,7 @@
default=None)
origin = attr.ib(
- type=Optional[Origin],
+ type=Optional[str],
validator=type_validator(),
default=None)
@@ -727,8 +727,7 @@
@classmethod
def from_dict(cls, d):
- d2 = d
- d = d.copy()
- if d.pop('data', None) is not None:
- raise ValueError('SkippedContent has no "data" attribute %r' % d2)
- return super().from_dict(d, use_subclass=False)
+ d2 = d.copy()
+ if d2.pop('data', None) is not None:
+ raise ValueError('SkippedContent has no "data" attribute %r' % d)
+ return super().from_dict(d2, use_subclass=False)
diff --git a/swh/model/tests/test_model.py b/swh/model/tests/test_model.py
--- a/swh/model/tests/test_model.py
+++ b/swh/model/tests/test_model.py
@@ -14,15 +14,15 @@
from swh.model.model import (
Content, SkippedContent, Directory, Revision, Release, Snapshot,
- Timestamp, TimestampWithTimezone,
+ Origin, Timestamp, TimestampWithTimezone,
MissingData, Person
)
from swh.model.hashutil import hash_to_bytes, MultiHash
from swh.model.hypothesis_strategies import (
- objects, origins, origin_visits, origin_visit_updates, timestamps
+ objects, origins, origin_visits, origin_visit_updates,
+ skipped_contents_d, timestamps
)
-
from swh.model.identifiers import (
directory_identifier, revision_identifier, release_identifier,
snapshot_identifier
@@ -386,6 +386,20 @@
assert getattr(c, key) == value
+@given(skipped_contents_d())
+def test_skipped_content_origin_is_str(skipped_content_d):
+ assert SkippedContent.from_dict(skipped_content_d)
+
+ skipped_content_d['origin'] = 'http://path/to/origin'
+ assert SkippedContent.from_dict(skipped_content_d)
+
+ skipped_content_d['origin'] = Origin(url='http://path/to/origin')
+ with pytest.raises(ValueError, match='origin'):
+ SkippedContent.from_dict(skipped_content_d)
+
+
+# ID computation
+
def test_directory_model_id_computation():
dir_dict = directory_example.copy()
del dir_dict['id']
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 20 2024, 12:55 AM (11 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3220885
Attached To
D2884: model: fix SkippedContent origin to be a str
Event Timeline
Log In to Comment