def test_max_instances_reached(self, scheduler, job, jobstore, executor, logstream): """Tests that a warning is logged when the maximum instances of a job is reached.""" executor.submit_job = MagicMock(side_effect=MaxInstancesReachedError(job)) assert scheduler._process_jobs() is None assert logstream.getvalue() == \ 'Execution of job "job 999" skipped: maximum number of running instances reached (1)\n'
def test_max_instances_reached(self, scheduler, job, jobstore, executor, caplog): """Tests that a warning is logged when the maximum instances of a job is reached.""" caplog.set_level(logging.WARNING) executor.submit_job = MagicMock(side_effect=MaxInstancesReachedError(job)) assert scheduler._process_jobs() is None assert len(caplog.records) == 1 assert caplog.records[0].message == \ 'Execution of job "job 999" skipped: maximum number of running instances reached (1)'
def test_max_instances_reached(self, scheduler, job, jobstore, executor, caplog, freeze_time): """Tests that a warning is logged when the maximum instances of a job is reached.""" caplog.set_level(logging.WARNING) executor.submit_job = MagicMock( side_effect=MaxInstancesReachedError(job)) job._get_run_times = MagicMock( return_value=[freeze_time.current - timedelta(seconds=30)]) assert scheduler._process_jobs() is None assert len(caplog.records) == 2 assert caplog.records[1].message == \ 'Execution of job "job 999" skipped: maximum number of running instances reached (1)'
def submit_job(self, job, run_times): raise MaxInstancesReachedError(job)