From 9bd8c0239c92be93491b3363c88a966120610284 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Thu, 8 Apr 2021 12:17:22 +0100 Subject: [PATCH] look for 'live', not 'production' config['NOTIFY_ENVIRONMENT'] is hardcoded to `'live'` in the Live config class. The values as seen on the environment which we send real messages from: ``` >>> json.loads(os.environ['VCAP_APPLICATION'])['space_name'] # what cloudfoundry sets 'production' >>> os.environ['NOTIFY_ENVIRONMENT'] # we set this from cloudfoundry 'production' >>> current_app.config['NOTIFY_ENVIRONMENT'] # hardcoded in the Live config 'live' >>> current_app.config['NOTIFICATION_QUEUE_PREFIX'] # pulled from env var of same name 'live' >>> current_app.config['ENV'] # this is an unrelated flask variable 'production' ``` --- app/celery/broadcast_message_tasks.py | 2 +- tests/app/celery/test_broadcast_message_tasks.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/celery/broadcast_message_tasks.py b/app/celery/broadcast_message_tasks.py index 8bf1f2316..6638fb197 100644 --- a/app/celery/broadcast_message_tasks.py +++ b/app/celery/broadcast_message_tasks.py @@ -112,7 +112,7 @@ def send_broadcast_event(broadcast_event_id): broadcast_event = dao_get_broadcast_event_by_id(broadcast_event_id) - if current_app.config['NOTIFY_ENVIRONMENT'] == 'production': + if current_app.config['NOTIFY_ENVIRONMENT'] == 'live': broadcast_message = broadcast_event.broadcast_message # raise a P1 to alert team that broadcast is going out. message = '\n'.join([ diff --git a/tests/app/celery/test_broadcast_message_tasks.py b/tests/app/celery/test_broadcast_message_tasks.py index a5cc2ffdb..848ef19ce 100644 --- a/tests/app/celery/test_broadcast_message_tasks.py +++ b/tests/app/celery/test_broadcast_message_tasks.py @@ -122,7 +122,7 @@ def test_send_broadcast_event_creates_zendesk_p1(mocker, notify_api, sample_broa mocker.patch('app.celery.broadcast_message_tasks.send_broadcast_provider_message') - with set_config(notify_api, 'NOTIFY_ENVIRONMENT', 'production'): + with set_config(notify_api, 'NOTIFY_ENVIRONMENT', 'live'): send_broadcast_event(event.id) assert mock_create_ticket.call_count == 1