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
4b779e1e
Verified
Commit
4b779e1e
authored
5 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
test_model: Simplify and align model checks
parent
b54adf79
No related branches found
Branches containing commit
Tags
v0.0.53
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/model/tests/test_model.py
+12
-28
12 additions, 28 deletions
swh/model/tests/test_model.py
with
12 additions
and
28 deletions
swh/model/tests/test_model.py
+
12
−
28
View file @
4b779e1e
...
@@ -66,26 +66,18 @@ def test_directory_model_id_computation():
...
@@ -66,26 +66,18 @@ def test_directory_model_id_computation():
dir_dict
=
dict
(
directory_example
)
dir_dict
=
dict
(
directory_example
)
del
dir_dict
[
'
id
'
]
del
dir_dict
[
'
id
'
]
dir_model
=
Directory
(
**
dir_dict
)
dir_id
=
hash_to_bytes
(
directory_identifier
(
dir_dict
))
assert
dir_model
.
id
for
dir_model
in
[
Directory
(
**
dir_dict
),
Directory
.
from_dict
(
dir_dict
)]:
assert
dir_model
.
id
==
hash_to_bytes
(
directory_identifier
(
dir_dict
))
assert
dir_model
.
id
==
dir_id
dir_model
=
Directory
.
from_dict
(
dir_dict
)
assert
dir_model
.
id
assert
dir_model
.
id
==
hash_to_bytes
(
directory_identifier
(
dir_dict
))
def
test_revision_model_id_computation
():
def
test_revision_model_id_computation
():
rev_dict
=
dict
(
revision_example
)
rev_dict
=
dict
(
revision_example
)
del
rev_dict
[
'
id
'
]
del
rev_dict
[
'
id
'
]
rev_model
=
Revision
(
**
rev_dict
)
rev_id
=
hash_to_bytes
(
revision_identifier
(
rev_dict
))
assert
rev_model
.
id
for
rev_model
in
[
Revision
(
**
rev_dict
),
Revision
.
from_dict
(
rev_dict
)]:
assert
rev_model
.
id
==
hash_to_bytes
(
revision_identifier
(
rev_dict
))
assert
rev_model
.
id
==
rev_id
rev_model
=
Revision
.
from_dict
(
rev_dict
)
assert
rev_model
.
id
assert
rev_model
.
id
==
hash_to_bytes
(
revision_identifier
(
rev_dict
))
def
test_revision_model_id_computation_with_no_date
():
def
test_revision_model_id_computation_with_no_date
():
...
@@ -108,23 +100,15 @@ def test_release_model_id_computation():
...
@@ -108,23 +100,15 @@ def test_release_model_id_computation():
rel_dict
=
dict
(
release_example
)
rel_dict
=
dict
(
release_example
)
del
rel_dict
[
'
id
'
]
del
rel_dict
[
'
id
'
]
rel_model
=
Release
(
**
rel_dict
)
rel_id
=
hash_to_bytes
(
release_identifier
(
rel_dict
))
assert
rel_model
.
id
for
rel_model
in
[
Release
(
**
rel_dict
),
Release
.
from_dict
(
rel_dict
)]:
assert
rel_model
.
id
==
hash_to_bytes
(
release_identifier
(
rel_dict
))
assert
rel_model
.
id
==
hash_to_bytes
(
rel_id
)
rel_model
=
Release
.
from_dict
(
rel_dict
)
assert
rel_model
.
id
assert
rel_model
.
id
==
hash_to_bytes
(
release_identifier
(
rel_dict
))
def
test_snapshot_model_id_computation
():
def
test_snapshot_model_id_computation
():
snp_dict
=
dict
(
snapshot_example
)
snp_dict
=
dict
(
snapshot_example
)
del
snp_dict
[
'
id
'
]
del
snp_dict
[
'
id
'
]
snp_model
=
Snapshot
(
**
snp_dict
)
snp_id
=
hash_to_bytes
(
snapshot_identifier
(
snp_dict
))
assert
snp_model
.
id
for
snp_model
in
[
Snapshot
(
**
snp_dict
),
Snapshot
.
from_dict
(
snp_dict
)]:
assert
snp_model
.
id
==
hash_to_bytes
(
snapshot_identifier
(
snp_dict
))
assert
snp_model
.
id
==
snp_id
snp_model
=
Snapshot
.
from_dict
(
snp_dict
)
assert
snp_model
.
id
assert
snp_model
.
id
==
hash_to_bytes
(
snapshot_identifier
(
snp_dict
))
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