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

@@ -1,7 +1,7 @@
import requests_mock
import pytest
import uuid
from datetime import (datetime, date)
from datetime import (datetime, date, timedelta)
from flask import current_app
@@ -288,6 +288,22 @@ def sample_job_with_placeholdered_template(
)
@pytest.fixture(scope='function')
def sample_scheduled_job(
notify_db,
notify_db_session,
service=None
):
return sample_job(
notify_db,
notify_db_session,
service=service,
template=sample_template_with_placeholders(notify_db, notify_db_session),
scheduled_for=(datetime.utcnow() + timedelta(minutes=60)).isoformat(),
job_status='scheduled'
)
@pytest.fixture(scope='function')
def sample_email_job(notify_db,
notify_db_session,