def test_from_string_error(self): s_short = '* *' s_long = '* * * *' with self.assertRaises(AttributeError): CronTime.from_string(s_short) with self.assertRaises(AttributeError): CronTime.from_string(s_long) s_day = [ '0 * *', '32 * *', '11-10 * *', '0-10 * *', '1-23/2 * *', 'a * *', '101/2 * *', '00/5 * *', '02 * *', '08-14 * *', '2//4 * *', '15-40 * *', '-8 * *', '1-5,02 * *', '*,22-33 * *' ] for d in s_day: with self.assertRaises(AttributeError): CronTime.from_string(d) s_month = ['* 0 *', '* 13 *', '* 5-15 *', '* 0-18 *'] for m in s_month: with self.assertRaises(AttributeError): CronTime.from_string(m) s_weekday = ['* * 0', '* * 10', '* * 3-10', '* * 0-7'] for w in s_weekday: with self.assertRaises(AttributeError): CronTime.from_string(w)
def test_from_string(self): self.assertEqual(CronTime('*', '*', '*'), CronTime.from_string(' * * * ')) self.assertEqual(CronTime('1-3,2/4,15', '3/5', '1,2,7'), CronTime.from_string('1-3,2/4,15 3/5 1,2,7 '))