Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 def get_available_units(self):
     self.assertIn('h', Time.get_available_units())
Esempio n. 4
0
 def test_units(self):
     time = Time('1.5h')
     self.assertEqual(time.units(), "h")
Esempio n. 5
0
 def test_value(self):
     time = Time('1.5h')
     self.assertEqual(time.value(), 1.5)
Esempio n. 6
0
 def test_bool(self):
     timez = Time(0)
     timen = Time(2)
     self.assertTrue(timen)
     self.assertFalse(timez)
Esempio n. 7
0
 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)