Merge pull request #3159 from alphagov/add-date-to-dvla-email-personalisation

Add date to personalisation for DVLA email
This commit is contained in:
Pea Tyczynska
2021-02-24 14:54:06 +00:00
committed by GitHub
4 changed files with 11 additions and 6 deletions
+4 -3
View File
@@ -181,10 +181,10 @@ def collate_letter_pdfs_to_be_sent():
def _get_letters_and_sheets_volumes_and_send_to_dvla(print_run_deadline): def _get_letters_and_sheets_volumes_and_send_to_dvla(print_run_deadline):
letters_volumes = dao_get_letters_and_sheets_volume_by_postage(print_run_deadline) letters_volumes = dao_get_letters_and_sheets_volume_by_postage(print_run_deadline)
send_letters_volume_email_to_dvla(letters_volumes) send_letters_volume_email_to_dvla(letters_volumes, print_run_deadline.date())
def send_letters_volume_email_to_dvla(letters_volumes): def send_letters_volume_email_to_dvla(letters_volumes, date):
personalisation = { personalisation = {
'total_volume': 0, 'total_volume': 0,
'first_class_volume': 0, 'first_class_volume': 0,
@@ -193,7 +193,8 @@ def send_letters_volume_email_to_dvla(letters_volumes):
'total_sheets': 0, 'total_sheets': 0,
'first_class_sheets': 0, 'first_class_sheets': 0,
"second_class_sheets": 0, "second_class_sheets": 0,
'international_sheets': 0 'international_sheets': 0,
'date': date.strftime("%d %B %Y")
} }
for item in letters_volumes: for item in letters_volumes:
personalisation['total_volume'] += item.letters_count personalisation['total_volume'] += item.letters_count
+1
View File
@@ -515,6 +515,7 @@ class Staging(Config):
FROM_NUMBER = 'stage' FROM_NUMBER = 'stage'
API_RATE_LIMIT_ENABLED = True API_RATE_LIMIT_ENABLED = True
CHECK_PROXY_HEADER = True CHECK_PROXY_HEADER = True
DVLA_EMAIL_ADDRESS = os.getenv('DVLA_EMAIL_ADDRESS')
class Live(Config): class Live(Config):
+2
View File
@@ -150,6 +150,8 @@ applications:
TEMPLATE_PREVIEW_API_HOST: '{{ TEMPLATE_PREVIEW_API_HOST }}' TEMPLATE_PREVIEW_API_HOST: '{{ TEMPLATE_PREVIEW_API_HOST }}'
TEMPLATE_PREVIEW_API_KEY: '{{ TEMPLATE_PREVIEW_API_KEY }}' TEMPLATE_PREVIEW_API_KEY: '{{ TEMPLATE_PREVIEW_API_KEY }}'
DVLA_EMAIL_ADDRESS: '{{ DVLA_EMAIL_ADDRESS }}'
{% for key, value in app.get('additional_env_vars', {}).items() %} {% for key, value in app.get('additional_env_vars', {}).items() %}
{{key}}: '{{value}}' {{key}}: '{{value}}'
{% endfor %} {% endfor %}
+4 -3
View File
@@ -396,7 +396,7 @@ def test_collate_letter_pdfs_to_be_sent(
mock_send_email_to_dvla.assert_called_once_with([ mock_send_email_to_dvla.assert_called_once_with([
(1, 1, 'europe'), (1, 1, 'first'), (1, 1, 'rest-of-world'), (4, 4, 'second') (1, 1, 'europe'), (1, 1, 'first'), (1, 1, 'rest-of-world'), (4, 4, 'second')
]) ], datetime(2020, 2, 17).date())
assert len(mock_celery.call_args_list) == 6 assert len(mock_celery.call_args_list) == 6
assert mock_celery.call_args_list[0] == call( assert mock_celery.call_args_list[0] == call(
@@ -476,7 +476,7 @@ def test_send_letters_volume_email_to_dvla(notify_api, notify_db_session, mocker
] ]
send_mock = mocker.patch('app.celery.provider_tasks.deliver_email.apply_async') send_mock = mocker.patch('app.celery.provider_tasks.deliver_email.apply_async')
send_letters_volume_email_to_dvla(letters_volumes) send_letters_volume_email_to_dvla(letters_volumes, datetime(2020, 2, 17).date())
email_to_dvla = get_notifications().all()[0] email_to_dvla = get_notifications().all()[0]
@@ -492,7 +492,8 @@ def test_send_letters_volume_email_to_dvla(notify_api, notify_db_session, mocker
'total_sheets': 24, 'total_sheets': 24,
'first_class_sheets': 7, 'first_class_sheets': 7,
"second_class_sheets": 12, "second_class_sheets": 12,
'international_sheets': 5 'international_sheets': 5,
'date': '17 February 2020'
} }