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
ac9d4c84
Commit
ac9d4c84
authored
5 years ago
by
David Douard
Browse files
Options
Downloads
Patches
Plain Diff
tests: add low level tests for the Timestamp model entity
parent
85ca7d78
No related branches found
Branches containing commit
Tags
debian/upstream/0.3.1
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
+29
-0
29 additions, 0 deletions
swh/model/tests/test_model.py
with
29 additions
and
0 deletions
swh/model/tests/test_model.py
+
29
−
0
View file @
ac9d4c84
...
...
@@ -6,6 +6,8 @@
import
copy
import
datetime
import
attr
from
attrs_strict
import
AttributeTypeError
from
hypothesis
import
given
from
hypothesis.strategies
import
binary
import
pytest
...
...
@@ -70,6 +72,33 @@ def test_todict_origin_visit_updates(origin_visit_update):
assert
origin_visit_update
==
type
(
origin_visit_update
).
from_dict
(
obj
)
def
test_timestamp_seconds
():
attr
.
validate
(
Timestamp
(
seconds
=
0
,
microseconds
=
0
))
with
pytest
.
raises
(
AttributeTypeError
):
Timestamp
(
seconds
=
'
0
'
,
microseconds
=
0
)
attr
.
validate
(
Timestamp
(
seconds
=
2
**
63
-
1
,
microseconds
=
0
))
with
pytest
.
raises
(
ValueError
):
Timestamp
(
seconds
=
2
**
63
,
microseconds
=
0
)
attr
.
validate
(
Timestamp
(
seconds
=-
2
**
63
,
microseconds
=
0
))
with
pytest
.
raises
(
ValueError
):
Timestamp
(
seconds
=-
2
**
63
-
1
,
microseconds
=
0
)
def
test_timestamp_microseconds
():
attr
.
validate
(
Timestamp
(
seconds
=
0
,
microseconds
=
0
))
with
pytest
.
raises
(
AttributeTypeError
):
Timestamp
(
seconds
=
0
,
microseconds
=
'
0
'
)
attr
.
validate
(
Timestamp
(
seconds
=
0
,
microseconds
=
10
**
6
-
1
))
with
pytest
.
raises
(
ValueError
):
Timestamp
(
seconds
=
0
,
microseconds
=
10
**
6
)
with
pytest
.
raises
(
ValueError
):
Timestamp
(
seconds
=
0
,
microseconds
=-
1
)
def
test_timestampwithtimezone_from_datetime
():
tz
=
datetime
.
timezone
(
datetime
.
timedelta
(
minutes
=+
60
))
date
=
datetime
.
datetime
(
...
...
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