mirror of
https://github.com/GSA/notifications-api.git
synced 2026-03-07 19:00:14 -05:00
Merge pull request #3162 from alphagov/change-dvla-addres-to-list
Change DVLA_EMAIL_ADDRESS to a list
This commit is contained in:
@@ -207,7 +207,7 @@ def send_letters_volume_email_to_dvla(letters_volumes, date):
|
||||
personalisation["international_sheets"] += item.sheets_count
|
||||
|
||||
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()
|
||||
service = Service.query.get(current_app.config['NOTIFY_SERVICE_ID'])
|
||||
|
||||
@@ -216,20 +216,20 @@ def send_letters_volume_email_to_dvla(letters_volumes, date):
|
||||
persist_notification,
|
||||
send_notification_to_queue
|
||||
)
|
||||
for recipient in recipients:
|
||||
saved_notification = persist_notification(
|
||||
template_id=template.id,
|
||||
template_version=template.version,
|
||||
recipient=recipient,
|
||||
service=service,
|
||||
personalisation=personalisation,
|
||||
notification_type=template.template_type,
|
||||
api_key_id=None,
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
reply_to_text=reply_to
|
||||
)
|
||||
|
||||
saved_notification = persist_notification(
|
||||
template_id=template.id,
|
||||
template_version=template.version,
|
||||
recipient=recipient,
|
||||
service=service,
|
||||
personalisation=personalisation,
|
||||
notification_type=template.template_type,
|
||||
api_key_id=None,
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
reply_to_text=reply_to
|
||||
)
|
||||
|
||||
send_notification_to_queue(saved_notification, False, queue=QueueNames.NOTIFY)
|
||||
send_notification_to_queue(saved_notification, False, queue=QueueNames.NOTIFY)
|
||||
|
||||
|
||||
def get_key_and_size_of_letters_to_be_sent_to_print(print_run_deadline, postage):
|
||||
|
||||
@@ -181,7 +181,7 @@ class Config(object):
|
||||
NOTIFY_INTERNATIONAL_SMS_SENDER = '07984404008'
|
||||
LETTERS_VOLUME_EMAIL_TEMPLATE_ID = '11fad854-fd38-4a7c-bd17-805fb13dfc12'
|
||||
# we only need real email in Live environment (production)
|
||||
DVLA_EMAIL_ADDRESS = 'success@simulator.amazonses.com'
|
||||
DVLA_EMAIL_ADDRESSES = json.loads(os.environ.get('DVLA_EMAIL_ADDRESSES', '[]'))
|
||||
|
||||
BROKER_URL = 'sqs://'
|
||||
BROKER_TRANSPORT_OPTIONS = {
|
||||
@@ -433,6 +433,7 @@ class Development(Config):
|
||||
|
||||
API_HOST_NAME = "http://localhost:6011"
|
||||
API_RATE_LIMIT_ENABLED = True
|
||||
DVLA_EMAIL_ADDRESSES = ['success@simulator.amazonses.com']
|
||||
|
||||
|
||||
class Test(Development):
|
||||
@@ -481,6 +482,7 @@ class Test(Development):
|
||||
FIRETEXT_URL = 'https://example.com/firetext'
|
||||
|
||||
CBC_PROXY_ENABLED = True
|
||||
DVLA_EMAIL_ADDRESSES = ['success@simulator.amazonses.com', 'success+2@simulator.amazonses.com']
|
||||
|
||||
|
||||
class Preview(Config):
|
||||
@@ -515,7 +517,6 @@ class Staging(Config):
|
||||
FROM_NUMBER = 'stage'
|
||||
API_RATE_LIMIT_ENABLED = True
|
||||
CHECK_PROXY_HEADER = True
|
||||
DVLA_EMAIL_ADDRESS = os.getenv('DVLA_EMAIL_ADDRESS')
|
||||
|
||||
|
||||
class Live(Config):
|
||||
@@ -539,7 +540,6 @@ class Live(Config):
|
||||
CRONITOR_ENABLED = True
|
||||
|
||||
ENABLED_CBCS = {BroadcastProvider.THREE, BroadcastProvider.O2, BroadcastProvider.VODAFONE}
|
||||
DVLA_EMAIL_ADDRESS = os.getenv('DVLA_EMAIL_ADDRESS')
|
||||
|
||||
|
||||
class CloudFoundryConfig(Config):
|
||||
|
||||
@@ -150,7 +150,7 @@ applications:
|
||||
TEMPLATE_PREVIEW_API_HOST: '{{ TEMPLATE_PREVIEW_API_HOST }}'
|
||||
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() %}
|
||||
{{key}}: '{{value}}'
|
||||
|
||||
@@ -478,23 +478,25 @@ 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())
|
||||
|
||||
email_to_dvla = get_notifications().all()[0]
|
||||
|
||||
send_mock.assert_called_once_with([str(email_to_dvla.id)], queue=QueueNames.NOTIFY)
|
||||
|
||||
assert str(email_to_dvla.template_id) == current_app.config['LETTERS_VOLUME_EMAIL_TEMPLATE_ID']
|
||||
assert email_to_dvla.to == current_app.config['DVLA_EMAIL_ADDRESS']
|
||||
assert email_to_dvla.personalisation == {
|
||||
'total_volume': 11,
|
||||
'first_class_volume': 5,
|
||||
'second_class_volume': 4,
|
||||
'international_volume': 2,
|
||||
'total_sheets': 24,
|
||||
'first_class_sheets': 7,
|
||||
"second_class_sheets": 12,
|
||||
'international_sheets': 5,
|
||||
'date': '17 February 2020'
|
||||
}
|
||||
emails_to_dvla = get_notifications().all()
|
||||
assert len(emails_to_dvla) == 2
|
||||
send_mock.called = 2
|
||||
send_mock.assert_any_call([str(emails_to_dvla[0].id)], queue=QueueNames.NOTIFY)
|
||||
send_mock.assert_any_call([str(emails_to_dvla[1].id)], queue=QueueNames.NOTIFY)
|
||||
for email in emails_to_dvla:
|
||||
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,
|
||||
'first_class_volume': 5,
|
||||
'second_class_volume': 4,
|
||||
'international_volume': 2,
|
||||
'total_sheets': 24,
|
||||
'first_class_sheets': 7,
|
||||
"second_class_sheets": 12,
|
||||
'international_sheets': 5,
|
||||
'date': '17 February 2020'
|
||||
}
|
||||
|
||||
|
||||
def test_group_letters_splits_on_file_size(notify_api):
|
||||
|
||||
Reference in New Issue
Block a user