Пример #1
0
  def test_check_value_hours(self):
    ts = scheduling_parser.parse_time_spec('25h')
    self.assertEqual(ts.value, 25)
    self.assertEqual(ts.unit, 'h')
    self.assertEqual(ts.minutes, 25*60)

    with self.assertRaises(ValueError):
      scheduling_parser.parse_time_spec('25h', check_value=True)
    def test_check_value_minutes(self):
        ts = scheduling_parser.parse_time_spec('75m')
        self.assertEqual(ts.value, 75)
        self.assertEqual(ts.unit, 'm')
        self.assertEqual(ts.minutes, 75)

        with self.assertRaises(ValueError):
            scheduling_parser.parse_time_spec('75m', check_value=True)
    def test_check_value_hours(self):
        ts = scheduling_parser.parse_time_spec('25h')
        self.assertEqual(ts.value, 25)
        self.assertEqual(ts.unit, 'h')
        self.assertEqual(ts.minutes, 25 * 60)

        with self.assertRaises(ValueError):
            scheduling_parser.parse_time_spec('25h', check_value=True)
Пример #4
0
  def test_check_value_minutes(self):
    ts = scheduling_parser.parse_time_spec('75m')
    self.assertEqual(ts.value, 75)
    self.assertEqual(ts.unit, 'm')
    self.assertEqual(ts.minutes, 75)

    with self.assertRaises(ValueError):
      scheduling_parser.parse_time_spec('75m', check_value=True)
Пример #5
0
 def test_hours(self):
   ts = scheduling_parser.parse_time_spec('2h')
   self.assertEqual(ts.value, 2)
   self.assertEqual(ts.unit, 'h')
   self.assertEqual(ts.minutes, 2*60)
 def test_hours(self):
     ts = scheduling_parser.parse_time_spec('2h')
     self.assertEqual(ts.value, 2)
     self.assertEqual(ts.unit, 'h')
     self.assertEqual(ts.minutes, 2 * 60)
Пример #7
0
 def test_day_name_capital(self):
   # capital letters are not supported.
   with self.assertRaises(ValueError):
     scheduling_parser.parse_time_spec('TUE')
Пример #8
0
 def test_utc_time_invalid_hours(self):
   with self.assertRaises(ValueError):
     scheduling_parser.parse_time_spec('25:00')
Пример #9
0
 def test_utc_time(self):
   ts = scheduling_parser.parse_time_spec('10:20')
   self.assertEqual(ts.value, 10*60 + 20)
   self.assertEqual(ts.unit, 'hm')
   self.assertEqual(ts.minutes, 10*60 + 20)
Пример #10
0
 def test_week(self):
   ts = scheduling_parser.parse_time_spec('4w')
   self.assertEqual(ts.value, 4)
   self.assertEqual(ts.unit, 'w')
   self.assertEqual(ts.minutes, 4*7*24*60)
 def test_utc_time_invalid_minutes(self):
     with self.assertRaises(ValueError):
         scheduling_parser.parse_time_spec('10:80')
 def test_utc_time(self):
     ts = scheduling_parser.parse_time_spec('10:20')
     self.assertEqual(ts.value, 10 * 60 + 20)
     self.assertEqual(ts.unit, 'hm')
     self.assertEqual(ts.minutes, 10 * 60 + 20)
 def test_invalid_unit(self):
     with self.assertRaises(ValueError):
         scheduling_parser.parse_time_spec('4t')
 def test_week(self):
     ts = scheduling_parser.parse_time_spec('4w')
     self.assertEqual(ts.value, 4)
     self.assertEqual(ts.unit, 'w')
     self.assertEqual(ts.minutes, 4 * 7 * 24 * 60)
 def test_day(self):
     ts = scheduling_parser.parse_time_spec('3d')
     self.assertEqual(ts.value, 3)
     self.assertEqual(ts.unit, 'd')
     self.assertEqual(ts.minutes, 3 * 24 * 60)
 def test_utc_time_invalid_hours(self):
     with self.assertRaises(ValueError):
         scheduling_parser.parse_time_spec('25:00')
Пример #17
0
 def test_day(self):
   ts = scheduling_parser.parse_time_spec('3d')
   self.assertEqual(ts.value, 3)
   self.assertEqual(ts.unit, 'd')
   self.assertEqual(ts.minutes, 3*24*60)
 def test_day_name(self):
     ts = scheduling_parser.parse_time_spec('tue')
     self.assertEqual(ts.value, 1)
     self.assertEqual(ts.unit, 'd')
     self.assertEqual(ts.minutes, 24 * 60)
Пример #19
0
 def test_invalid_unit(self):
   with self.assertRaises(ValueError):
     scheduling_parser.parse_time_spec('4t')
 def test_day_name_capital(self):
     # capital letters are not supported.
     with self.assertRaises(ValueError):
         scheduling_parser.parse_time_spec('TUE')
Пример #21
0
 def test_utc_time_invalid_minutes(self):
   with self.assertRaises(ValueError):
     scheduling_parser.parse_time_spec('10:80')
 def test_invalid_input(self):
     with self.assertRaises(ValueError):
         scheduling_parser.parse_time_spec('garbage')
Пример #23
0
 def test_day_name(self):
   ts = scheduling_parser.parse_time_spec('tue')
   self.assertEqual(ts.value, 1)
   self.assertEqual(ts.unit, 'd')
   self.assertEqual(ts.minutes, 24*60)
Пример #24
0
 def test_minutes(self):
   ts = scheduling_parser.parse_time_spec('1m')
   self.assertEqual(ts.value, 1)
   self.assertEqual(ts.unit, 'm')
   self.assertEqual(ts.minutes, 1)
Пример #25
0
 def test_invalid_input(self):
   with self.assertRaises(ValueError):
     scheduling_parser.parse_time_spec('garbage')
 def test_minutes(self):
     ts = scheduling_parser.parse_time_spec('1m')
     self.assertEqual(ts.value, 1)
     self.assertEqual(ts.unit, 'm')
     self.assertEqual(ts.minutes, 1)