def test_from_timestamp(self): # Correct offset: UTC+2, should return datetime + tzoffset(+2) altz = utctz_to_altz('+0200') self.assertEqual(datetime.fromtimestamp(1522827734, tzoffset(altz)), from_timestamp(1522827734, altz)) # Wrong offset: UTC+58, should return datetime + tzoffset(UTC) altz = utctz_to_altz('+5800') self.assertEqual(datetime.fromtimestamp(1522827734, tzoffset(0)), from_timestamp(1522827734, altz)) # Wrong offset: UTC-9000, should return datetime + tzoffset(UTC) altz = utctz_to_altz('-9000') self.assertEqual(datetime.fromtimestamp(1522827734, tzoffset(0)), from_timestamp(1522827734, altz))
def assert_rval(rval, veri_time, offset=0): assert len(rval) == 2 assert isinstance(rval[0], int) and isinstance(rval[1], int) assert rval[0] == veri_time assert rval[1] == offset # now that we are here, test our conversion functions as well utctz = altz_to_utctz_str(offset) assert isinstance(utctz, string_types) assert utctz_to_altz(verify_utctz(utctz)) == offset
def assert_rval(rval, veri_time, offset=0): self.assertEqual(len(rval), 2) self.assertIsInstance(rval[0], int) self.assertIsInstance(rval[1], int) self.assertEqual(rval[0], veri_time) self.assertEqual(rval[1], offset) # now that we are here, test our conversion functions as well utctz = altz_to_utctz_str(offset) self.assertIsInstance(utctz, string_types) self.assertEqual(utctz_to_altz(verify_utctz(utctz)), offset)