Change DVLA_EMAIL_ADDRESS to a list

This commit is contained in:
Rebecca Law
2021-02-26 11:21:16 +00:00
parent b120b83cc7
commit acfb759cb9
4 changed files with 39 additions and 35 deletions
+2 -2
View File
@@ -207,7 +207,7 @@ def send_letters_volume_email_to_dvla(letters_volumes, date):
personalisation["international_sheets"] += item.sheets_count personalisation["international_sheets"] += item.sheets_count
template = dao_get_template_by_id(current_app.config['LETTERS_VOLUME_EMAIL_TEMPLATE_ID']) template = dao_get_template_by_id(current_app.config['LETTERS_VOLUME_EMAIL_TEMPLATE_ID'])
recipient = current_app.config['DVLA_EMAIL_ADDRESS'] recipients = current_app.config['DVLA_EMAIL_ADDRESSES']
reply_to = template.service.get_default_reply_to_email_address() reply_to = template.service.get_default_reply_to_email_address()
service = Service.query.get(current_app.config['NOTIFY_SERVICE_ID']) service = Service.query.get(current_app.config['NOTIFY_SERVICE_ID'])
@@ -216,7 +216,7 @@ def send_letters_volume_email_to_dvla(letters_volumes, date):
persist_notification, persist_notification,
send_notification_to_queue send_notification_to_queue
) )
for recipient in recipients:
saved_notification = persist_notification( saved_notification = persist_notification(
template_id=template.id, template_id=template.id,
template_version=template.version, template_version=template.version,
+5 -3
View File
@@ -181,7 +181,7 @@ class Config(object):
NOTIFY_INTERNATIONAL_SMS_SENDER = '07984404008' NOTIFY_INTERNATIONAL_SMS_SENDER = '07984404008'
LETTERS_VOLUME_EMAIL_TEMPLATE_ID = '11fad854-fd38-4a7c-bd17-805fb13dfc12' LETTERS_VOLUME_EMAIL_TEMPLATE_ID = '11fad854-fd38-4a7c-bd17-805fb13dfc12'
# we only need real email in Live environment (production) # we only need real email in Live environment (production)
DVLA_EMAIL_ADDRESS = 'success@simulator.amazonses.com' DVLA_EMAIL_ADDRESSES = ['success@simulator.amazonses.com']
BROKER_URL = 'sqs://' BROKER_URL = 'sqs://'
BROKER_TRANSPORT_OPTIONS = { BROKER_TRANSPORT_OPTIONS = {
@@ -482,6 +482,8 @@ class Test(Development):
CBC_PROXY_ENABLED = True CBC_PROXY_ENABLED = True
DVLA_EMAIL_ADDRESSES = ['success@simulator.amazonses.com', 'success+2@simulator.amazonses.com']
class Preview(Config): class Preview(Config):
NOTIFY_EMAIL_DOMAIN = 'notify.works' NOTIFY_EMAIL_DOMAIN = 'notify.works'
@@ -515,7 +517,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') DVLA_EMAIL_ADDRESSES = os.getenv('DVLA_EMAIL_ADDRESSES')
class Live(Config): class Live(Config):
@@ -539,7 +541,7 @@ class Live(Config):
CRONITOR_ENABLED = True CRONITOR_ENABLED = True
ENABLED_CBCS = {BroadcastProvider.THREE, BroadcastProvider.O2, BroadcastProvider.VODAFONE} ENABLED_CBCS = {BroadcastProvider.THREE, BroadcastProvider.O2, BroadcastProvider.VODAFONE}
DVLA_EMAIL_ADDRESS = os.getenv('DVLA_EMAIL_ADDRESS') DVLA_EMAIL_ADDRESSES = os.getenv('DVLA_EMAIL_ADDRESSES')
class CloudFoundryConfig(Config): class CloudFoundryConfig(Config):
+1 -1
View File
@@ -150,7 +150,7 @@ 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 }}' DVLA_EMAIL_ADDRESSES: '{{ DVLA_EMAIL_ADDRESSES | tojson }}'
{% for key, value in app.get('additional_env_vars', {}).items() %} {% for key, value in app.get('additional_env_vars', {}).items() %}
{{key}}: '{{value}}' {{key}}: '{{value}}'
+9 -7
View File
@@ -478,13 +478,15 @@ def test_send_letters_volume_email_to_dvla(notify_api, notify_db_session, mocker
send_letters_volume_email_to_dvla(letters_volumes, datetime(2020, 2, 17).date()) send_letters_volume_email_to_dvla(letters_volumes, datetime(2020, 2, 17).date())
email_to_dvla = get_notifications().all()[0] emails_to_dvla = get_notifications().all()
assert len(emails_to_dvla) == 2
send_mock.assert_called_once_with([str(email_to_dvla.id)], queue=QueueNames.NOTIFY) send_mock.called = 2
send_mock.assert_any_call([str(emails_to_dvla[0].id)], queue=QueueNames.NOTIFY)
assert str(email_to_dvla.template_id) == current_app.config['LETTERS_VOLUME_EMAIL_TEMPLATE_ID'] send_mock.assert_any_call([str(emails_to_dvla[1].id)], queue=QueueNames.NOTIFY)
assert email_to_dvla.to == current_app.config['DVLA_EMAIL_ADDRESS'] for email in emails_to_dvla:
assert email_to_dvla.personalisation == { assert str(email.template_id) == current_app.config['LETTERS_VOLUME_EMAIL_TEMPLATE_ID']
assert email.to in current_app.config['DVLA_EMAIL_ADDRESSES']
assert email.personalisation == {
'total_volume': 11, 'total_volume': 11,
'first_class_volume': 5, 'first_class_volume': 5,
'second_class_volume': 4, 'second_class_volume': 4,