def test_same_func_diff_triggers(self): trigger_a = IntervalTrigger(timedelta(hours=1)) trigger_b = IntervalTrigger(timedelta(hours=2)) def test_fn(): pass test_fn_a = periodic_task(priority=9, run_every=trigger_a)(test_fn) test_fn_b = periodic_task(priority=9, run_every=trigger_b)(test_fn) job = Mock(trigger=trigger_a, func=test_fn_a) jobs_to_unschedule, tasks_to_add = process_periodic_tasks( [job], [test_fn_b]) self.assertEqual(jobs_to_unschedule, [job]) self.assertEqual(tasks_to_add, [test_fn_b])
def test_same_func_diff_priorities(self): # This test isn't strictly necessary, since APScheduler doesn't store # priority information to db, it loads it from the module each time. # Were that to change, this should fail! trigger = IntervalTrigger(timedelta(hours=1)) def test_fn(): pass test_fn_a = periodic_task(priority=9, run_every=trigger)(test_fn) test_fn_b = periodic_task(priority=8, run_every=trigger)(test_fn) job = Mock(trigger=trigger, func=test_fn_a) jobs_to_unschedule, tasks_to_add = process_periodic_tasks( [job], [test_fn_b]) self.assertEqual(jobs_to_unschedule, [job]) self.assertEqual(tasks_to_add, [test_fn_b])