Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_identifiers.py
Show All 35 Lines | |||||
class UtilityFunctionsDateOffset(unittest.TestCase): | class UtilityFunctionsDateOffset(unittest.TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.dates = { | self.dates = { | ||||
b"1448210036": {"seconds": 1448210036, "microseconds": 0,}, | b"1448210036": {"seconds": 1448210036, "microseconds": 0,}, | ||||
b"1448210036.002342": {"seconds": 1448210036, "microseconds": 2342,}, | b"1448210036.002342": {"seconds": 1448210036, "microseconds": 2342,}, | ||||
b"1448210036.12": {"seconds": 1448210036, "microseconds": 120000,}, | b"1448210036.12": {"seconds": 1448210036, "microseconds": 120000,}, | ||||
} | } | ||||
self.offsets = { | |||||
0: b"+0000", | |||||
-630: b"-1030", | |||||
800: b"+1320", | |||||
} | |||||
def test_format_date(self): | def test_format_date(self): | ||||
for date_repr, date in self.dates.items(): | for date_repr, date in self.dates.items(): | ||||
self.assertEqual(git_objects.format_date(date), date_repr) | self.assertEqual(git_objects.format_date(date), date_repr) | ||||
def test_format_offset(self): | |||||
for offset, res in self.offsets.items(): | |||||
self.assertEqual(git_objects.format_offset(offset), res) | |||||
content_example = { | content_example = { | ||||
"status": "visible", | "status": "visible", | ||||
"length": 5, | "length": 5, | ||||
"data": b"1984\n", | "data": b"1984\n", | ||||
"ctime": datetime.datetime(2015, 11, 22, 16, 33, 56, tzinfo=datetime.timezone.utc), | "ctime": datetime.datetime(2015, 11, 22, 16, 33, 56, tzinfo=datetime.timezone.utc), | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,145 Lines • Show Last 20 Lines |