Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-model
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Renaud Boyer
swh-model
Commits
b2c21d32
Commit
b2c21d32
authored
5 years ago
by
Nicolas Dandrimont
Browse files
Options
Downloads
Patches
Plain Diff
Don't export origin_visit['origin']['type']
parent
7a9fc396
Loading
Loading
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/model/model.py
+1
-0
1 addition, 0 deletions
swh/model/model.py
swh/model/tests/test_model.py
+11
-2
11 additions, 2 deletions
swh/model/tests/test_model.py
with
12 additions
and
2 deletions
swh/model/model.py
+
1
−
0
View file @
b2c21d32
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
swh/model/tests/test_model.py
+
11
−
2
View file @
b2c21d32
...
...
@@ -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
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment