Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/tests/test_converters.py
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | |||||
def test_svn_date_to_swh_date(): | def test_svn_date_to_swh_date(): | ||||
"""The timestamp should not be tampered with and include the | """The timestamp should not be tampered with and include the | ||||
decimals. | decimals. | ||||
""" | """ | ||||
assert converters.svn_date_to_swh_date( | assert converters.svn_date_to_swh_date( | ||||
"2011-05-31T06:04:39.500900Z" | b"2011-05-31T06:04:39.500900Z" | ||||
) == TimestampWithTimezone( | ) == TimestampWithTimezone( | ||||
timestamp=Timestamp(seconds=1306821879, microseconds=500900), | timestamp=Timestamp(seconds=1306821879, microseconds=500900), | ||||
offset=0, | offset=0, | ||||
negative_utc=False, | negative_utc=False, | ||||
) | ) | ||||
assert converters.svn_date_to_swh_date( | assert converters.svn_date_to_swh_date( | ||||
"2011-05-31T06:04:39.800722Z" | b"2011-05-31T06:04:39.800722Z" | ||||
) == TimestampWithTimezone( | ) == TimestampWithTimezone( | ||||
timestamp=Timestamp(seconds=1306821879, microseconds=800722), | timestamp=Timestamp(seconds=1306821879, microseconds=800722), | ||||
offset=0, | offset=0, | ||||
negative_utc=False, | negative_utc=False, | ||||
) | ) | ||||
def test_svn_date_to_swh_date_epoch(): | def test_svn_date_to_swh_date_epoch(): | ||||
"""Empty date should be EPOCH (timestamp and offset at 0).""" | """Empty date should be EPOCH (timestamp and offset at 0).""" | ||||
# It should return 0, epoch | # It should return 0, epoch | ||||
default_tstz = TimestampWithTimezone( | default_tstz = TimestampWithTimezone( | ||||
timestamp=Timestamp(seconds=0, microseconds=0), offset=0, negative_utc=False, | timestamp=Timestamp(seconds=0, microseconds=0), offset=0, negative_utc=False, | ||||
) | ) | ||||
assert converters.svn_date_to_swh_date("") == default_tstz | assert converters.svn_date_to_swh_date("") == default_tstz | ||||
assert converters.svn_date_to_swh_date(None) == default_tstz | assert converters.svn_date_to_swh_date(None) == default_tstz |