diff --git a/jobrunner/create_or_update_jobs.py b/jobrunner/create_or_update_jobs.py index 7597d0ea..b633d6dc 100644 --- a/jobrunner/create_or_update_jobs.py +++ b/jobrunner/create_or_update_jobs.py @@ -289,7 +289,7 @@ def assert_new_jobs_created(job_request, new_jobs, current_jobs): # is treated as a successful outcome because we've already done everything that was # requested. if RUN_ALL_COMMAND in job_request.requested_actions: - raise NothingToDoError() + raise NothingToDoError("All actions have already completed succesfully") # The other reason is that every requested action is already running or pending, # this is considered a user error. @@ -298,7 +298,7 @@ def assert_new_jobs_created(job_request, new_jobs, current_jobs): current_job_states.get(action) for action in job_request.requested_actions } if requested_action_states <= {State.PENDING, State.RUNNING}: - raise JobRequestError("All requested actions were already scheduled to run") + raise NothingToDoError("All requested actions were already scheduled to run") # But if we get here then we've somehow failed to schedule new jobs despite the fact # that some of the actions we depend on have failed, which is a bug. diff --git a/tests/test_create_or_update_jobs.py b/tests/test_create_or_update_jobs.py index 23919f2c..b4df9c73 100644 --- a/tests/test_create_or_update_jobs.py +++ b/tests/test_create_or_update_jobs.py @@ -285,6 +285,15 @@ def make_job_request(action=None, actions=None, **kwargs): return job_request +def test_create_jobs_already_requested(db, tmp_work_dir): + create_jobs_with_project_file(make_job_request(action="analyse_data"), TEST_PROJECT) + + with pytest.raises(NothingToDoError): + create_jobs_with_project_file( + make_job_request(action="analyse_data"), TEST_PROJECT + ) + + def create_jobs_with_project_file(job_request, project_file): with mock.patch("jobrunner.create_or_update_jobs.get_project_file") as f: f.return_value = project_file