def test_operations(self): time0 = Time("3600s") time1 = Time("1h") time2 = Time("59m") self.assertEqual(time0, time1) self.assertNotEqual(time0, time2) self.assertGreaterEqual(time0, time1) self.assertLessEqual(time0, time1) self.assertGreater(time0, time2) self.assertLess(time2, time0)
def human(self): for time_i, (time_s, time_hs) in self._times.items(): time = Time(time_i) time_h = Time(time_hs) time_human = time.human() self.assertEqual(time_human, time_h) self.assertEqual(time_human.units(), time_h.units()) self.assertEqual(str(time_human), time_hs)
def get_available_units(self): self.assertIn('h', Time.get_available_units())
def test_units(self): time = Time('1.5h') self.assertEqual(time.units(), "h")
def test_value(self): time = Time('1.5h') self.assertEqual(time.value(), 1.5)
def test_bool(self): timez = Time(0) timen = Time(2) self.assertTrue(timen) self.assertFalse(timez)
def constructor(self): for time_i, (time_s, time_hs) in self._times.items(): time = Time(time_i) time_h = Time(time_hs) self.assertEqual(time.get_seconds(), time_s)