def test_now_returns_iso8601Z_timestamp_microseconds(self, mock_datetime): """ ``now()`` returns the current UTC time in iso8601 zulu format """ mock_datetime.utcnow.return_value = datetime( 2000, 01, 01, 12, 0, 0, 111111, None) self.assertEqual(timestamp.now(), "2000-01-01T12:00:00.111111Z")
def test_from_timestamp_can_read_now_timestamp(self, mock_datetime): """ ``from_timestamp`` can parse timestamps produced by ``now()`` """ mock_datetime.utcnow.return_value = datetime( 2000, 01, 01, 12, 0, 0, 0, None) parsed = timestamp.from_timestamp(timestamp.now()) # can't compare naive and timestamp-aware datetimes, so check that # the parsed timezone is not None. Then replace with None to compare. self.assertTrue(parsed.tzinfo is not None) self.assertEqual(parsed.replace(tzinfo=None), mock_datetime.utcnow.return_value)