Exemple #1
0
 def test_seconds_frac(self):
     result = TimeParser.duration_to_string(timedelta(seconds=1.17))
     self.assertEqual(result, 'PT00H00M01,1700S')
Exemple #2
0
 def test_parse_error_no_months(self):
     with self.assertRaises(ValueError):
         TimeParser.parse('2000')
Exemple #3
0
 def test_just_days(self):
     result = TimeParser.duration_to_string(timedelta(days=7))
     self.assertEqual(result, 'P7DT00H00M00S')
Exemple #4
0
 def test_just_minutes(self):
     result = TimeParser.duration_to_string(timedelta(minutes=7))
     self.assertEqual(result, 'PT00H07M00S')
Exemple #5
0
 def test_just_days(self):
     result = TimeParser.duration_to_string(timedelta(days=7))
     self.assertEqual(result, 'P7DT00H00M00S')
Exemple #6
0
 def test_seconds_frac(self):
     result = TimeParser.duration_to_string(timedelta(seconds=1.17))
     self.assertEqual(result, 'PT00H00M01,1700S')
Exemple #7
0
 def test_to_string(self):
     p = TimeParser('2000-01-01T12:00:00')
     self.assertEqual(str(p), '2000-01-01T12:00:00')
Exemple #8
0
 def test_just_seconds_frac(self):
     result = TimeParser.duration_parser("PT1,50S")
     expected = timedelta(seconds=1.5)
     self.assertEqual(result, expected)
Exemple #9
0
 def test_parse_error_no_minutes(self):
     with self.assertRaises(ValueError):
         TimeParser.parse('2000-01-01T12')
Exemple #10
0
 def test_datetime_value(self):
     p = TimeParser('2000-01-01T12:00:00')
     self.assertEqual(p.value, datetime(2000, 1, 1, 12))
Exemple #11
0
 def test_parse_error_no_seconds(self):
     with self.assertRaises(ValueError):
         TimeParser.parse('2000-01-01T12:00')
Exemple #12
0
 def test_is_datetime(self):
     p = TimeParser('2000-01-01T12:00:00')
     self.assertTrue(p.is_date)
     self.assertTrue(p.has_time)
Exemple #13
0
 def test_date_value(self):
     p = TimeParser('2000-01-01')
     self.assertEqual(p.value, date(2000, 1, 1))
Exemple #14
0
 def test_parse_error_no_minutes(self):
     with self.assertRaises(ValueError):
         TimeParser.parse('2000-01-01T12')
Exemple #15
0
 def test_is_time(self):
     p = TimeParser('PT00H05M00,0000S')
     self.assertTrue(p.is_duration)
Exemple #16
0
 def test_just_hours(self):
     result = TimeParser.duration_parser("PT1H")
     expected = timedelta(hours=1)
     self.assertEqual(result, expected)
Exemple #17
0
 def test_time_value_5min(self):
     p = TimeParser('PT0H05M00,0000S')
     self.assertEqual(p.value, timedelta(minutes=5))
Exemple #18
0
 def test_mix_hrs_min(self):
     result = TimeParser.duration_parser("PT02H05M")
     expected = timedelta(hours=2, minutes=5)
     self.assertEqual(result, expected)
Exemple #19
0
 def test_time_value_1hr(self):
     p = TimeParser('PT1H00M00,0000S')
     self.assertEqual(p.value, timedelta(hours=1))
Exemple #20
0
 def test_just_minutes(self):
     result = TimeParser.duration_to_string(timedelta(minutes=7))
     self.assertEqual(result, 'PT00H07M00S')
Exemple #21
0
 def test_to_string(self):
     p = TimeParser('PT1H00M00,0000S')
     self.assertEqual(str(p), 'PT01H00M00S')
Exemple #22
0
 def test_parse_error_no_months(self):
     with self.assertRaises(ValueError):
         TimeParser.parse('2000')
Exemple #23
0
 def test_set_timedelta(self):
     p = TimeParser(timedelta(minutes=5))
     self.assertEqual('PT00H05M00S', str(p))
Exemple #24
0
 def test_just_hours(self):
     result = TimeParser.duration_to_string(timedelta(hours=7))
     self.assertEqual(result, 'PT07H00M00S')
Exemple #25
0
 def test_set_date(self):
     p = TimeParser(date(2011, 2, 5))
     self.assertEqual('2011-02-05', str(p))
Exemple #26
0
 def test_just_seconds(self):
     result = TimeParser.duration_to_string(timedelta(seconds=7))
     self.assertEqual(result, 'PT00H00M07S')
Exemple #27
0
 def test_set_datetime(self):
     p = TimeParser(datetime(2011, 2, 5, 12, 0, 0))
     self.assertEqual('2011-02-05T12:00:00', str(p))
Exemple #28
0
 def test_days_hours_min_sec_frac(self):
     result = TimeParser.duration_to_string(
         timedelta(days=7, hours=5, minutes=45, seconds=1.789))
     self.assertEqual(result, 'P7DT05H45M01,7890S')
Exemple #29
0
 def test_init_as_class(self):
     p = TimeParser('2000-01-01')
     self.assertIsNotNone(p)
Exemple #30
0
 def test_parse_error_no_seconds(self):
     with self.assertRaises(ValueError):
         TimeParser.parse('2000-01-01T12:00')
Exemple #31
0
 def test_just_days(self):
     result = TimeParser.duration_parser("P7D")
     expected = timedelta(days=7)
     self.assertEqual(result, expected)
Exemple #32
0
 def test_just_days(self):
     result = TimeParser.duration_parser("P7D")
     expected = timedelta(days=7)
     self.assertEqual(result, expected)
Exemple #33
0
 def test_just_hours(self):
     result = TimeParser.duration_parser("PT1H")
     expected = timedelta(hours=1)
     self.assertEqual(result, expected)
Exemple #34
0
 def test_just_minutes(self):
     result = TimeParser.duration_parser("PT1M")
     expected = timedelta(minutes=1)
     self.assertEqual(result, expected)
Exemple #35
0
 def test_just_minutes(self):
     result = TimeParser.duration_parser("PT1M")
     expected = timedelta(minutes=1)
     self.assertEqual(result, expected)
Exemple #36
0
 def test_mix_hrs_min_sec_frac(self):
     result = TimeParser.duration_parser("PT2H5M1,50S")
     expected = timedelta(hours=2, minutes=5, seconds=1.5)
     self.assertEqual(result, expected)
Exemple #37
0
 def test_just_seconds_frac(self):
     result = TimeParser.duration_parser("PT1,50S")
     expected = timedelta(seconds=1.5)
     self.assertEqual(result, expected)
Exemple #38
0
 def test_parse_error(self):
     with self.assertRaises(ValueError):
         TimeParser.duration_parser("T02H05M")
Exemple #39
0
 def test_mix_hrs_min_sec_frac(self):
     result = TimeParser.duration_parser("PT2H5M1,50S")
     expected = timedelta(hours=2, minutes=5, seconds=1.5)
     self.assertEqual(result, expected)
Exemple #40
0
 def test_just_hours(self):
     result = TimeParser.duration_to_string(timedelta(hours=7))
     self.assertEqual(result, 'PT07H00M00S')
Exemple #41
0
 def test_mix_hrs_min(self):
     result = TimeParser.duration_parser("PT02H05M")
     expected = timedelta(hours=2, minutes=5)
     self.assertEqual(result, expected)
Exemple #42
0
 def test_just_seconds(self):
     result = TimeParser.duration_to_string(timedelta(seconds=7))
     self.assertEqual(result, 'PT00H00M07S')
Exemple #43
0
 def test_parse_error(self):
     with self.assertRaises(ValueError):
         TimeParser.duration_parser("T02H05M")
Exemple #44
0
 def test_days_hours_min_sec_frac(self):
     result = TimeParser.duration_to_string(timedelta(days=7, hours=5, minutes=45, seconds=1.789))
     self.assertEqual(result, 'P7DT05H45M01,7890S')
Exemple #45
0
 def test_is_date(self):
     p = TimeParser('2000-01-01')
     self.assertTrue(p.is_date)
     self.assertFalse(p.has_time)