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
7a9fc396
Commit
7a9fc396
authored
5 years ago
by
Nicolas Dandrimont
Browse files
Options
Downloads
Patches
Plain Diff
model: Don't export origin['type']
parent
c103a6f9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/model/model.py
+5
-0
5 additions, 0 deletions
swh/model/model.py
swh/model/tests/test_model.py
+13
-1
13 additions, 1 deletion
swh/model/tests/test_model.py
with
18 additions
and
1 deletion
swh/model/model.py
+
5
−
0
View file @
7a9fc396
...
...
@@ -97,6 +97,11 @@ class Origin(BaseModel):
url
=
attr
.
ib
(
type
=
str
)
type
=
attr
.
ib
(
type
=
Optional
[
str
],
default
=
None
)
def
to_dict
(
self
):
r
=
super
().
to_dict
()
r
.
pop
(
'
type
'
,
None
)
return
r
@attr.s
class
OriginVisit
(
BaseModel
):
...
...
This diff is collapsed.
Click to expand it.
swh/model/tests/test_model.py
+
13
−
1
View file @
7a9fc396
...
...
@@ -8,12 +8,16 @@ import copy
from
hypothesis
import
given
from
swh.model.model
import
Content
from
swh.model.hypothesis_strategies
import
objects
from
swh.model.hypothesis_strategies
import
objects
,
origins
@given
(
objects
())
def
test_todict_inverse_fromdict
(
objtype_and_obj
):
(
obj_type
,
obj
)
=
objtype_and_obj
if
obj_type
==
'
origin
'
:
return
obj_as_dict
=
obj
.
to_dict
()
obj_as_dict_copy
=
copy
.
deepcopy
(
obj_as_dict
)
...
...
@@ -27,6 +31,14 @@ def test_todict_inverse_fromdict(objtype_and_obj):
assert
obj_as_dict
==
type
(
obj
).
from_dict
(
obj_as_dict
).
to_dict
()
@given
(
origins
())
def
test_todict_origins
(
origin
):
obj
=
origin
.
to_dict
()
assert
'
type
'
not
in
obj
assert
type
(
origin
)(
url
=
origin
.
url
)
==
type
(
origin
).
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