def test_run_all(self): mock_job = make_mock_job() every().minute.do(mock_job) every().hour.do(mock_job) every().day.at('11:00').do(mock_job) schedule_utc.run_all() assert mock_job.call_count == 3
def test_cancel_jobs(self): def stop_job(): return schedule_utc.CancelJob every().second.do(stop_job) every().second.do(stop_job) every().second.do(stop_job) assert len(schedule_utc.jobs) == 3 schedule_utc.run_all() assert len(schedule_utc.jobs) == 0
def test_clear_by_tag(self): every().second.do(make_mock_job(name='job1')).tag('tag1') every().second.do(make_mock_job(name='job2')).tag('tag1', 'tag2') every().second.do(make_mock_job(name='job3')).tag( 'tag3', 'tag3', 'tag3', 'tag2') assert len(schedule_utc.jobs) == 3 schedule_utc.run_all() assert len(schedule_utc.jobs) == 3 schedule_utc.clear('tag3') assert len(schedule_utc.jobs) == 2 schedule_utc.clear('tag1') assert len(schedule_utc.jobs) == 0 every().second.do(make_mock_job(name='job1')) every().second.do(make_mock_job(name='job2')) every().second.do(make_mock_job(name='job3')) schedule_utc.clear() assert len(schedule_utc.jobs) == 0
def test_cancel_job(self): def stop_job(): return schedule_utc.CancelJob mock_job = make_mock_job() every().second.do(stop_job) mj = every().second.do(mock_job) assert len(schedule_utc.jobs) == 2 schedule_utc.run_all() assert len(schedule_utc.jobs) == 1 assert schedule_utc.jobs[0] == mj schedule_utc.cancel_job('Not a job') assert len(schedule_utc.jobs) == 1 schedule_utc.default_scheduler.cancel_job('Not a job') assert len(schedule_utc.jobs) == 1 schedule_utc.cancel_job(mj) assert len(schedule_utc.jobs) == 0
def test_job_func_args_are_passed_on(self): mock_job = make_mock_job() every().second.do(mock_job, 1, 2, 'three', foo=23, bar={}) schedule_utc.run_all() mock_job.assert_called_once_with(1, 2, 'three', foo=23, bar={})