def test_get_expiry_date(self): self.assertIsInstance(get_expiry_date(minutes=60), datetime) date1 = utcnow() + timedelta(minutes=60) date2 = get_expiry_date(minutes=60) self.assertEqual(date1.year, date2.year) self.assertEqual(date1.month, date2.month) self.assertEqual(date1.day, date2.day) self.assertEqual(date1.hour, date2.hour) self.assertEqual(date1.minute, date2.minute) self.assertEqual(date1.second, date2.second)
def test_get_expiry_date_with_offset(self): offset = utcnow() + timedelta(minutes=10) date1 = offset + timedelta(minutes=5) date2 = get_expiry_date(minutes=5, offset=offset) self.assertEqual(date1.year, date2.year) self.assertEqual(date1.month, date2.month) self.assertEqual(date1.day, date2.day) self.assertEqual(date1.hour, date2.hour) self.assertEqual(date1.minute, date2.minute) self.assertEqual(date1.second, date2.second)
def test_get_expiry_date_bad_offset_raises_error(self): with assert_raises(TypeError) as error_context: offset = '01.02.2013 13:30' get_expiry_date(minutes=5, offset=offset)