Skip to content
Snippets Groups Projects
Commit ac9d4c84 authored by David Douard's avatar David Douard
Browse files

tests: add low level tests for the Timestamp model entity

parent 85ca7d78
No related branches found
Tags debian/upstream/0.3.1
No related merge requests found
......@@ -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(
......
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