Add a task for the FTP app to call that will update the job to sent to dvla and all the notifications for that job as sending.

This commit is contained in:
Rebecca Law
2017-04-06 17:16:08 +01:00
parent 895b5d13dd
commit add0cfa62f
5 changed files with 55 additions and 18 deletions

View File

@@ -19,7 +19,8 @@ from app.celery.tasks import (
send_sms,
send_email,
persist_letter,
get_template_class
get_template_class,
update_job_to_sent_to_dvla
)
from app.dao import jobs_dao, services_dao
from app.models import (
@@ -1036,3 +1037,14 @@ def test_dvla_letter_template(sample_letter_notification):
sample_letter_notification.personalisation,
12345)
assert str(letter) == "140|500|001||201703230012345|||||||||||||A1|A2|A3|A4|A5|A6||A_POST|||||||||23 March 2017<cr><cr><h1>Template subject<normal><cr><cr>Dear Sir/Madam, Hello. Yours Truly, The Government.<cr><cr>" # noqa
def test_update_job_to_sent_to_dvla(sample_letter_template, sample_letter_job):
create_notification(template=sample_letter_template, job=sample_letter_job)
create_notification(template=sample_letter_template, job=sample_letter_job)
update_job_to_sent_to_dvla(job_id=sample_letter_job.id)
updated_notifications = Notification.query.all()
assert [(n.status == 'sending', n.sent_by == 'dvla') for n in updated_notifications]
assert 'sent to dvla' == Job.query.filter_by(id=sample_letter_job.id).one().job_status

View File

@@ -52,7 +52,6 @@ from tests.app.conftest import (
sample_email_template,
sample_service,
sample_job,
sample_api_key,
sample_notification_history as create_notification_history
)

View File

@@ -673,7 +673,8 @@ def test_get_jobs_accepts_page_parameter(
@pytest.mark.parametrize('statuses_filter, expected_statuses', [
('', JOB_STATUS_TYPES),
('pending', [JOB_STATUS_PENDING]),
('pending, in progress, finished, sending limits exceeded, scheduled, cancelled', JOB_STATUS_TYPES),
('pending, in progress, finished, sending limits exceeded, scheduled, cancelled, ready to send, sent to dvla',
JOB_STATUS_TYPES),
# bad statuses are accepted, just return no data
('foo', [])
])
@@ -691,6 +692,8 @@ def test_get_jobs_can_filter_on_statuses(
create_job(notify_db, notify_db_session, job_status='sending limits exceeded')
create_job(notify_db, notify_db_session, job_status='scheduled')
create_job(notify_db, notify_db_session, job_status='cancelled')
create_job(notify_db, notify_db_session, job_status='ready to send')
create_job(notify_db, notify_db_session, job_status='sent to dvla')
path = '/service/{}/job'.format(sample_service.id)
response = client.get(