From 37a5ce601a6d42d46c8d89160b66dd76aea76e4d Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Fri, 24 Mar 2017 15:25:02 +0000 Subject: [PATCH] Update the version of notifications-utils. There was a problem with the address block for the DVLATemplate. Added a countdown to the build_dvla_file. --- app/celery/tasks.py | 2 +- requirements.txt | 2 +- tests/app/celery/test_tasks.py | 12 +++++++++++- tests/app/conftest.py | 2 ++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/celery/tasks.py b/app/celery/tasks.py index c4ea9731f..a868a76dc 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -262,7 +262,7 @@ def persist_letter( handle_exception(self, notification, notification_id, e) -@notify_celery.task(bind=True, name="build-dvla-file", max_retries=15, default_retry_delay=300) +@notify_celery.task(bind=True, name="build-dvla-file", countdown=30, max_retries=15, default_retry_delay=300) @statsd(namespace="tasks") def build_dvla_file(self, job_id): try: diff --git a/requirements.txt b/requirements.txt index 0f73d102e..5dbd4246c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,6 +29,6 @@ notifications-python-client>=3.1,<3.2 awscli>=1.11,<1.12 awscli-cwlogs>=1.4,<1.5 -git+https://github.com/alphagov/notifications-utils.git@13.8.0#egg=notifications-utils==13.8.0 +git+https://github.com/alphagov/notifications-utils.git@13.9.5#egg=notifications-utils==13.9.5 git+https://github.com/alphagov/boto.git@2.43.0-patch3#egg=boto==2.43.0-patch3 diff --git a/tests/app/celery/test_tasks.py b/tests/app/celery/test_tasks.py index e792400ed..f0f1d9a3a 100644 --- a/tests/app/celery/test_tasks.py +++ b/tests/app/celery/test_tasks.py @@ -6,7 +6,7 @@ import pytest from flask import current_app from freezegun import freeze_time from sqlalchemy.exc import SQLAlchemyError -from notifications_utils.template import SMSMessageTemplate, WithSubjectTemplate +from notifications_utils.template import SMSMessageTemplate, WithSubjectTemplate, LetterDVLATemplate from celery.exceptions import Retry from app import (encryption, DATETIME_FORMAT) @@ -996,3 +996,13 @@ def test_build_dvla_file_retries_if_all_notifications_are_not_created(sample_let tasks.build_dvla_file.retry.assert_called_with(queue='retry', exc="All notifications for job {} are not persisted".format(job.id)) + + +@freeze_time("2017-03-23 11:09:00.061258") +def test_dvla_letter_template(sample_letter_notification): + t = {"content": sample_letter_notification.template.content, + "subject": sample_letter_notification.template.subject} + letter = LetterDVLATemplate(t, + sample_letter_notification.personalisation, + 12345) + assert str(letter) == "140|001|001||201703230012345|23032017||||||||||||A1|A2|A3|A4|A5|A6||A_POST||||||||Template subject|Dear Sir/Madam, Hello. Yours Truly, The Government." # noqa diff --git a/tests/app/conftest.py b/tests/app/conftest.py index 53ffc0081..387bb33eb 100644 --- a/tests/app/conftest.py +++ b/tests/app/conftest.py @@ -495,6 +495,8 @@ def sample_letter_notification(sample_letter_template): 'addressline2': 'A2', 'addressline3': 'A3', 'addressline4': 'A4', + 'addressline5': 'A5', + 'addressline6': 'A6', 'postcode': 'A_POST' } return create_notification(sample_letter_template, personalisation=address)