def test_utc_times(self): self.assertEqual(parse_time({'time': '0:00', 'tz': 'Z'}), td(0)) self.assertEqual(parse_time({'time': '00:00', 'tz': 'Z'}), td(0)) self.assertEqual(parse_time({'time': '01:00', 'tz': 'Z'}), td(hours=1)) self.assertEqual(parse_time({'time': '01:00', 'tz': 'Z'}), td(hours=1)) self.assertEqual(parse_time({ 'time': '00:01', 'tz': 'Z' }), td(minutes=1))
def test_tz__times(self): self.assertEqual(parse_time({ 'time': '0:00', 'tz': '+1:00' }), td(hours=23)) self.assertEqual(parse_time({ 'time': '00:00', 'tz': '+1:00' }), td(hours=23)) self.assertEqual(parse_time({'time': '01:00', 'tz': '+1:00'}), td(0)) self.assertEqual(parse_time({'time': '01:00', 'tz': '+1:00'}), td(0)) self.assertEqual(parse_time({ 'time': '02:00', 'tz': '+1:00' }), td(hours=1)) self.assertEqual(parse_time({ 'time': '02:00', 'tz': '+1:00' }), td(hours=1)) self.assertEqual(parse_time({ 'time': '00:01', 'tz': '+1:00' }), td(hours=23, minutes=1))
def test_naked_times(self): # naked times should be equivalent to UTC self.assertEqual(parse_time({'time': '0:00'}), td(0)) self.assertEqual(parse_time({'time': '00:00'}), td(0)) self.assertEqual(parse_time({'time': '01:00'}), td(hours=1)) self.assertEqual(parse_time({'time': '01:00'}), td(hours=1)) self.assertEqual(parse_time({'time': '00:01'}), td(minutes=1))
def test_with_seconds(self): self.assertEqual(parse_time({'time': '00:00:00'}), td(0))
def test_bad_time(self): self.assertEqual(parse_time({'time': 'none'}), td(0))
def test_None_time(self): self.assertEqual(parse_time({'time': None}), td(0))
def test_badtz(self): self.assertEqual(parse_time({'time': '0:00', 'tz': 'Y'}), td(0))