def test_build_timer_cron(self): s1 = app.build_timer(self.app, "* 1 * 2 *", self.tick) self.assertIs(IServiceCollection(self.app), s1.parent) self.assertIsInstance(s1, cron.CrontabTimerService) self.assertEqual("* 1 * 2 *", s1.cronline) s2 = app.build_timer(self.app, ['*', '5-10', '*', '*', '*'], self.tick) self.assertIs(IServiceCollection(self.app), s1.parent) self.assertIsInstance(s1, cron.CrontabTimerService) self.assertEqual("* 5-10 * * *", s2.cronline)
def test_build_interval(self): s1 = app.build_timer(self.app, 1234, self.tick) self.assertIs(IServiceCollection(self.app), s1.parent) self.assertIsInstance(s1, cron.IntervalTimerService) self.assertEqual(1234, s1.interval) s1 = app.build_timer(self.app, " 999 ", self.tick) self.assertIs(IServiceCollection(self.app), s1.parent) self.assertIsInstance(s1, cron.IntervalTimerService) self.assertEqual(999, s1.interval)