def setUp(self): self.registry = TaskRegistry() self.registry.register(DuePeriodicTask) self.registry.register(PendingPeriodicTask) self.scheduler = beat.Scheduler(self.registry, max_interval=0.0001, logger=log.get_default_logger())
def test_schedule_equal_none_entry_vs_none_entry(self): scheduler = beat.Scheduler(app=self.app) a = None b = None assert scheduler.schedules_equal(a, b)
def test_schedule_equal_entry_vs_none_entry(self): scheduler = beat.Scheduler(app=self.app) a = {'a': self.create_schedule_entry(task='a')} b = None assert not scheduler.schedules_equal(a, b)
def test_schedule_equal_task_vs_task_fail(self): scheduler = beat.Scheduler(app=self.app) a = {'a': self.create_schedule_entry(task='a')} b = {'a': self.create_schedule_entry(task='b')} assert not scheduler.schedules_equal(a, b)
def test_schedule_equal_options_vs_options_fail(self): scheduler = beat.Scheduler(app=self.app) a = {'a': self.create_schedule_entry(options={'a': 'a'})} b = {'a': self.create_schedule_entry(options={'b': 'b'})} assert not scheduler.schedules_equal(a, b)
def test_schedule_equal_kwargs_vs_kwargs_success(self): scheduler = beat.Scheduler(app=self.app) a = {'a': self.create_schedule_entry(kwargs={'a': 'a'})} b = {'a': self.create_schedule_entry(kwargs={'a': 'a'})} assert scheduler.schedules_equal(a, b)
def test_schedule_equal_different_key_fail(self): scheduler = beat.Scheduler(app=self.app) a = {'a': self.create_schedule_entry(schedule=schedule(5))} b = {'b': self.create_schedule_entry(schedule=schedule(5))} assert not scheduler.schedules_equal(a, b)
def test_schedule_equal_crontab_vs_schedule_fail(self): scheduler = beat.Scheduler(app=self.app) a = {'a': self.create_schedule_entry(schedule=crontab(minute=5))} b = {'a': self.create_schedule_entry(schedule=schedule(5))} assert not scheduler.schedules_equal(a, b)
def test_schedule_equal_schedule_vs_schedule_success(self): scheduler = beat.Scheduler(app=self.app) a = {'a': self.create_schedule_entry(schedule=schedule(5))} b = {'a': self.create_schedule_entry(schedule=schedule(5))} assert scheduler.schedules_equal(a, b)
def test_send_task(self, send_task): b = beat.Scheduler(app=self.app) b.send_task('tasks.add', countdown=10) send_task.assert_called_with('tasks.add', countdown=10)
def test_send_task(self, send_task): b = beat.Scheduler() b.send_task("tasks.add", countdown=10) send_task.assert_called_with("tasks.add", countdown=10)
def test_schedule_equal_crontab_vs_crontab_success(self): scheduler = beat.Scheduler(app=self.app) a = {'a': self.create_schedule_entry(crontab(minute=5))} b = {'a': self.create_schedule_entry(crontab(minute=5))} assert scheduler.schedules_equal(a, b)
def test_schedule_equal_schedule_vs_schedule_fail(self): scheduler = beat.Scheduler(app=self.app) a = {'a': self.create_schedule_entry(schedule(5))} b = {'a': self.create_schedule_entry(schedule(10))} assert not scheduler.schedules_equal(a, b)
def test_constructor(self): s = beat.Scheduler() self.assertIsInstance(s.registry, TaskRegistry) self.assertIsInstance(s.schedule, dict) self.assertIsInstance(s.logger, logging.Logger) self.assertEqual(s.max_interval, conf.CELERYBEAT_MAX_LOOP_INTERVAL)