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:
Chris Hill-Scott
2016-09-01 14:31:01 +01:00
parent aa8ee3a8da
commit 4a7267be8b
7 changed files with 92 additions and 2 deletions

View File

@@ -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