def test_converting_timedelta_to_validity(self): self.assertEqual(to_relative(timedelta(minutes=5)), 0) self.assertEqual(to_relative(timedelta(minutes=6)), 0) self.assertEqual(to_relative(timedelta(minutes=10)), 1) self.assertEqual(to_relative(timedelta(hours=12)), 143) self.assertEqual(to_relative(timedelta(hours=13)), 145) self.assertEqual(to_relative(timedelta(hours=24)), 167) self.assertEqual(to_relative(timedelta(days=2)), 168) self.assertEqual(to_relative(timedelta(days=30)), 196)
def test_converting_timedelta_to_validity(self): self.assertRaises(ValueError, to_relative, timedelta(minutes=4)) self.assertRaises(ValueError, to_relative, timedelta(weeks=64)) self.assertTrue(isinstance(to_relative(timedelta(hours=6)), int)) self.assertTrue(isinstance(to_relative(timedelta(hours=18)), int)) self.assertTrue(isinstance(to_relative(timedelta(days=15)), int)) self.assertTrue(isinstance(to_relative(timedelta(weeks=31)), int)) self.assertEqual(to_relative(timedelta(minutes=5)), 0) self.assertEqual(to_relative(timedelta(minutes=6)), 0) self.assertEqual(to_relative(timedelta(minutes=10)), 1) self.assertEqual(to_relative(timedelta(hours=12)), 143) self.assertEqual(to_relative(timedelta(hours=13)), 145) self.assertEqual(to_relative(timedelta(hours=24)), 167) self.assertEqual(to_relative(timedelta(days=2)), 168) self.assertEqual(to_relative(timedelta(days=30)), 196)