Example #1
0
 def test_comparing_time_string_with_same_time_string_returns_true(self):
     dates = {
         '0000': TimeString('0000'),
         '0815': TimeString('0815'),
         '2359': TimeString('2359')
     }
     for s, ds in dates.items():
         self.assertTrue(TimeString(s).compare_with(ds))
Example #2
0
 def test_comparing_time_string_with_future_time_string_returns_false(self):
     dates = {
         '0000': TimeString('0101'),
         '0815': TimeString('0816'),
         '2259': TimeString('2359')
     }
     for s, ds in dates.items():
         self.assertFalse(TimeString(s).compare_with(ds))
Example #3
0
 def test_comparing_time_string_with_same_datetime_returns_true(self):
     dates = {
         '0000': datetime(year=2000, month=1, day=1, hour=0, minute=0),
         '0815': datetime(year=2000, month=1, day=1, hour=8, minute=15),
         '2359': datetime(year=2000, month=1, day=1, hour=23, minute=59)
     }
     for s, dt in dates.items():
         self.assertTrue(TimeString(s).compare_with_datetime(dt))
Example #4
0
 def test_comparing_time_string_with_past_datetime_returns_false(self):
     dates = {
         '0101': datetime(year=2000, month=1, day=1, hour=0, minute=0),
         '0815': datetime(year=2000, month=1, day=1, hour=8, minute=14),
         '2359': datetime(year=2000, month=1, day=1, hour=22, minute=59)
     }
     for s, dt in dates.items():
         self.assertFalse(TimeString(s).compare_with_datetime(dt))
Example #5
0
 def test_comparing_time_string_with_same_string_returns_true(self):
     dates = {
         '0000': '0000',
         '0815': '0815',
         '2359': '2359'
     }
     for s, string in dates.items():
         self.assertTrue(TimeString(s).compare_with_string(string))
Example #6
0
 def test_comparing_time_string_with_future_string_returns_false(self):
     dates = {
         '0000': '0101',
         '0815': '0816',
         '2259': '2359'
     }
     for s, string in dates.items():
         self.assertFalse(TimeString(s).compare_with_string(string))
Example #7
0
 def test_comparing_time_string_with_future_datetime_returns_false(self):
     dates = {
         '0000': datetime(year=2000, month=1, day=1, hour=1, minute=1),
         '0815': datetime(year=2000, month=1, day=1, hour=8, minute=16),
         '2259': datetime(year=2000, month=1, day=1, hour=23, minute=59)
     }
     for s, dt in dates.items():
         self.assertFalse(TimeString(s).compare_with_datetime(dt))
Example #8
0
    def test_initializing_timestring_with_str_0_returns_0000(self):
        expected = '0000'
        ts = TimeString('0')
        actual = str(ts)

        self.assertEqual(expected, actual)
Example #9
0
 def test_1337_is_valid_timestring(self):
     self.assertTrue(TimeString.is_valid_time_string('1337'))
Example #10
0
 def test_2359_is_valid_timestring(self):
     self.assertTrue(TimeString.is_valid_time_string('2359'))
Example #11
0
 def test_leet_is_not_valid_timestring(self):
     self.assertFalse(TimeString.is_valid_time_string('leet'))
Example #12
0
    def test_leftpad_0_returns_0000(self):
        expected = '0000'
        actual = TimeString.left_pad('0')

        self.assertEqual(expected, actual)
Example #13
0
    def test_leftpad_leet_returns_leet(self):
        expected = 'leet'
        actual = TimeString.left_pad('leet')

        self.assertEqual(expected, actual)
Example #14
0
 def test_int_7_is_not_valid_timestring(self):
     self.assertFalse(TimeString.is_valid_time_string(7))
Example #15
0
 def test_0x05_is_not_valid_timestring(self):
     self.assertFalse(TimeString.is_valid_time_string('0x05'))
Example #16
0
 def test_0dot01_is_not_valid_timestring(self):
     self.assertFalse(TimeString.is_valid_time_string('0.01'))
Example #17
0
 def test_01337_is_not_valid_timestring(self):
     self.assertFalse(TimeString.is_valid_time_string('01337'))
Example #18
0
 def test_00minus1_is_not_valid_timestring(self):
     self.assertFalse(TimeString.is_valid_time_string('00-1'))
Example #19
0
 def test_2400_is_not_valid_timestring(self):
     self.assertFalse(TimeString.is_valid_time_string('2400'))
Example #20
0
 def test_0000_converts_correct(self):
     expected = '2359'
     actual = TimeString.convert_from_datetime(datetime(year=2000, month=1, day=1, hour=23, minute=59))
     self.assertEqual(expected, str(actual))
Example #21
0
    def test_initializing_timestring_with_str_2359_returns_2359(self):
        expected = '2359'
        ts = TimeString('2359')
        actual = str(ts)

        self.assertEqual(expected, actual)
Example #22
0
 def test_0000_is_valid_timestring(self):
     self.assertTrue(TimeString.is_valid_time_string('0000'))
Example #23
0
    def test_leftpad_01234_returns_01234(self):
        expected = '01234'
        actual = TimeString.left_pad('01234')

        self.assertEqual(expected, actual)
Example #24
0
 def test_9999_is_not_valid_timestring(self):
     self.assertFalse(TimeString.is_valid_time_string('9999'))
Example #25
0
    def test_leftpad_minus1_returns_00minus1(self):
        expected = '00-1'
        actual = TimeString.left_pad('-1')

        self.assertEqual(expected, actual)
Example #26
0
 def setTime(self, time):
     self._time = TimeString(time)