def test_deserialise_with_local_datetime(self): """ This tests that a datetime without timezone information is interpreted as a local time """ log = Log.from_json('{"data": "Wagtail 0.5 released", "time": "2014-08-01T11:01:42", "pk": null}') expected_time = timezone.make_aware(self.WAGTAIL_05_RELEASE_DATETIME, timezone.get_default_timezone()) self.assertEqual(log.time, expected_time) self.assertEqual(log.time.tzinfo, expected_time.tzinfo)
def test_deserialise_with_local_datetime(self): """ This tests that a datetime without timezone information is interpreted as a local time """ log = Log.from_json('{"data": "Wagtail 0.5 released", "time": "2014-08-01T11:01:42", "pk": null}') expected_time = timezone.make_aware(self.WAGTAIL_05_RELEASE_DATETIME, timezone.get_default_timezone()) self.assertEqual(log.time, expected_time) self.assertEqual(log.time.tzinfo, expected_time.tzinfo)
def test_deserialise_with_utc_datetime(self): """ This tests that a datetimes saved as UTC are converted back correctly """ # Time is in UTC log = Log.from_json('{"data": "Wagtail 0.5 released", "time": "2014-08-01T16:01:42Z", "pk": null}') # Naive and aware timezones cannot be compared so make the release date timezone-aware before comparison expected_time = timezone.make_aware(self.WAGTAIL_05_RELEASE_DATETIME, timezone.get_default_timezone()) # Check that the datetime is correct and was converted back into the correct timezone self.assertEqual(log.time, expected_time) self.assertEqual(log.time.tzinfo, expected_time.tzinfo)
def test_deserialise_with_utc_datetime(self): """ This tests that a datetimes saved as UTC are converted back correctly """ # Time is in UTC log = Log.from_json('{"data": "Wagtail 0.5 released", "time": "2014-08-01T16:01:42Z", "pk": null}') # Naive and aware timezones cannot be compared so make the release date timezone-aware before comparison expected_time = timezone.make_aware(self.WAGTAIL_05_RELEASE_DATETIME, timezone.get_default_timezone()) # Check that the datetime is correct and was converted back into the correct timezone self.assertEqual(log.time, expected_time) self.assertEqual(log.time.tzinfo, expected_time.tzinfo)
def test_deserialise_with_null_datetime(self): log = Log.from_json('{"data": "Someone scanned a QR code", "time": null, "pk": null}') self.assertEqual(log.time, None)
def test_deserialise_with_null_datetime(self): log = Log.from_json('{"data": "Someone scanned a QR code", "time": null, "pk": null}') self.assertEqual(log.time, None)