示例#1
0
    def test_parse_hour(self):
        time = _parse_hour('01')
        self.assertEqual(time, datetime.time(hour=1))

        time = _parse_hour('24')
        self.assertEqual(time, datetime.time(hour=0))

        time = _parse_hour('01.4567')
        self.assertEqual(
            time,
            datetime.time(hour=1, minute=27, second=24, microsecond=120000))

        time = _parse_hour('12.5')
        self.assertEqual(time, datetime.time(hour=12, minute=30))
示例#2
0
    def test_parse_hour(self):
        testtuples = (('01', None, {
            'hh': '01',
            'tz': None
        }), ('24', None, {
            'tz': None
        }), ('01.4567', None, {
            'hh': '01.4567',
            'tz': None
        }), ('12.5', None, {
            'hh': '12.5',
            'tz': None
        }), ('08', (True, None, '12', '34', '-12:34', 'timezone'), {
            'hh': '08',
            'tz': (True, None, '12', '34', '-12:34', 'timezone')
        }))

        for testtuple in testtuples:
            mockBuilder = mock.Mock()

            mockBuilder.build_time.return_value = testtuple[2]

            result = _parse_hour(testtuple[0], testtuple[1], mockBuilder)

            self.assertEqual(result, testtuple[2])
            mockBuilder.build_time.assert_called_once_with(**testtuple[2])
示例#3
0
    def test_parse_hour(self):
        time = _parse_hour('01')
        self.assertEqual(time.hour, 1)

        time = _parse_hour('24')
        self.assertEqual(time.hour, 0)

        time = _parse_hour('01.4567')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 27)
        self.assertEqual(time.second, 24)
        self.assertEqual(time.microsecond, 120000)

        time = _parse_hour('12.5')
        self.assertEqual(time.hour, 12)
        self.assertEqual(time.minute, 30)
    def test_parse_hour(self):
        time = _parse_hour('01')
        self.assertEqual(time.hour, 1)

        time = _parse_hour('24')
        self.assertEqual(time.hour, 0)

        time = _parse_hour('01.4567')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 27)
        self.assertEqual(time.second, 24)
        self.assertEqual(time.microsecond, 120000)

        time = _parse_hour('12.5')
        self.assertEqual(time.hour, 12)
        self.assertEqual(time.minute, 30)
示例#5
0
    def test_parse_hour(self):
        testtuples = (('01', None, {'hh': '01', 'tz': None}),
                      ('24', None, {'tz': None}),
                      ('01.4567', None, {'hh': '01.4567', 'tz': None}),
                      ('12.5', None, {'hh': '12.5', 'tz': None}),
                      ('08', (True, None, '12', '34', '-12:34', 'timezone'),
                       {'hh': '08', 'tz':
                        (True, None, '12', '34', '-12:34', 'timezone')}))

        for testtuple in testtuples:
            mockBuilder = mock.Mock()

            mockBuilder.build_time.return_value = testtuple[2]

            result = _parse_hour(testtuple[0], testtuple[1], mockBuilder)

            self.assertEqual(result, testtuple[2])
            mockBuilder.build_time.assert_called_once_with(**testtuple[2])
    def test_parse_hour(self):
        testtuples = (
            ("01", None, {"hh": "01", "tz": None}),
            ("24", None, {"tz": None}),
            ("01.4567", None, {"hh": "01.4567", "tz": None}),
            ("12.5", None, {"hh": "12.5", "tz": None}),
            (
                "08",
                (True, None, "12", "34", "-12:34", "timezone"),
                {"hh": "08", "tz": (True, None, "12", "34", "-12:34", "timezone")},
            ),
        )

        for testtuple in testtuples:
            mockBuilder = mock.Mock()

            mockBuilder.build_time.return_value = testtuple[2]

            result = _parse_hour(testtuple[0], testtuple[1], mockBuilder)

            self.assertEqual(result, testtuple[2])
            mockBuilder.build_time.assert_called_once_with(**testtuple[2])
示例#7
0
 def test_parse_hour_bounds(self):
     #Hour cannot be larger than 24
     with self.assertRaises(HoursOutOfBoundsError):
         _parse_hour('24.1')