Skip to content
Snippets Groups Projects
Commit b2c21d32 authored by Nicolas Dandrimont's avatar Nicolas Dandrimont
Browse files

Don't export origin_visit['origin']['type']

parent 7a9fc396
Loading
......@@ -127,6 +127,7 @@ class OriginVisit(BaseModel):
ov = super().to_dict()
if ov['visit'] is None:
del ov['visit']
ov['origin'] = self.origin.to_dict()
return ov
@classmethod
......
......@@ -8,14 +8,14 @@ import copy
from hypothesis import given
from swh.model.model import Content
from swh.model.hypothesis_strategies import objects, origins
from swh.model.hypothesis_strategies import objects, origins, origin_visits
@given(objects())
def test_todict_inverse_fromdict(objtype_and_obj):
(obj_type, obj) = objtype_and_obj
if obj_type == 'origin':
if obj_type in ('origin', 'origin_visit'):
return
obj_as_dict = obj.to_dict()
......@@ -39,6 +39,15 @@ def test_todict_origins(origin):
assert type(origin)(url=origin.url) == type(origin).from_dict(obj)
@given(origin_visits())
def test_todict_origin_visits(origin_visit):
obj = origin_visit.to_dict()
assert 'type' not in obj['origin']
origin_visit.origin.type = None
assert origin_visit == type(origin_visit).from_dict(obj)
def test_content_get_hash():
hashes = dict(
sha1=b'foo', sha1_git=b'bar', sha256=b'baz', blake2s256=b'qux')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment