mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Add an endpoint to cancel a job
If you schedule a job you might change your mind or circumstances might change. So you need to be able to cancel it. This commit adds a `POST` endpoint for individual jobs which sets their status to `cancelled`. This also means adding a new status of `cancelled`, so there’s a migration…
This commit is contained in:
@@ -7,6 +7,7 @@ from app.dao.jobs_dao import (
|
||||
dao_update_job,
|
||||
dao_get_jobs_by_service_id,
|
||||
dao_get_scheduled_jobs,
|
||||
dao_get_future_scheduled_job_by_id_and_service_id,
|
||||
dao_get_notification_outcomes_for_job
|
||||
)
|
||||
|
||||
@@ -251,3 +252,10 @@ def test_get_scheduled_jobs_gets_ignores_jobs_scheduled_in_the_future(notify_db,
|
||||
sample_job(notify_db, notify_db_session, scheduled_for=one_minute_in_the_future, job_status='scheduled')
|
||||
jobs = dao_get_scheduled_jobs()
|
||||
assert len(jobs) == 0
|
||||
|
||||
|
||||
def test_get_future_scheduled_job_gets_a_job_yet_to_send(notify_db, notify_db_session):
|
||||
one_hour_from_now = datetime.utcnow() + timedelta(minutes=60)
|
||||
job = sample_job(notify_db, notify_db_session, scheduled_for=one_hour_from_now, job_status='scheduled')
|
||||
result = dao_get_future_scheduled_job_by_id_and_service_id(job.id, job.service_id)
|
||||
assert result.id == job.id
|
||||
|
||||
Reference in New Issue
Block a user