mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 08:51:30 -05:00
Favour new "areas" format for PagerDuty alerts
Broadcasts created via the API [1] and the Admin app [2] should both now have this field set. It's also more informative to show this, and broadcasts created via the API don't have IDs anyway. There's a small risk that an old broadcast that gets approved won't have this data, but it's for information only and we intend to backfill all old broadcasts in the near future. [1]:023a06d5fb[2]:7dbe3afa19
This commit is contained in:
@@ -135,7 +135,7 @@ def send_broadcast_event(broadcast_event_id):
|
||||
f'https://www.notifications.service.gov.uk/services/{broadcast_message.service_id}/current-alerts/{broadcast_message.id}', # noqa
|
||||
'',
|
||||
f'This broacast has been sent on channel {broadcast_message.service.broadcast_channel}.',
|
||||
f'This broadcast is targeted at areas {broadcast_message.areas.get("ids", broadcast_message.areas.get("areas"))}.', # noqa
|
||||
f'This broadcast is targeted at areas {broadcast_message.areas.get("names", [])}.', # noqa
|
||||
''
|
||||
f'This broadcast\'s content starts "{broadcast_message.content[:100]}"'
|
||||
'',
|
||||
|
||||
@@ -95,12 +95,22 @@ def test_send_broadcast_event_does_nothing_if_provider_set_on_service_isnt_enabl
|
||||
assert mock_send_broadcast_provider_message.apply_async.called is False
|
||||
|
||||
|
||||
def test_send_broadcast_event_creates_zendesk_p1(mocker, notify_api, sample_broadcast_service):
|
||||
@pytest.mark.parametrize('area_data,expected_message', [
|
||||
({'names': ['England', 'Scotland']}, ['England', 'Scotland']),
|
||||
({}, [])
|
||||
])
|
||||
def test_send_broadcast_event_creates_zendesk_p1(
|
||||
area_data,
|
||||
expected_message,
|
||||
mocker,
|
||||
notify_api,
|
||||
sample_broadcast_service
|
||||
):
|
||||
template = create_template(sample_broadcast_service, BROADCAST_TYPE)
|
||||
broadcast_message = create_broadcast_message(
|
||||
template,
|
||||
status=BroadcastStatusType.BROADCASTING,
|
||||
areas={'ids': ['wd20-S13002775', 'wd20-S13002773'], 'simple_polygons': []},
|
||||
areas={**area_data, 'simple_polygons': []},
|
||||
)
|
||||
event = create_broadcast_event(broadcast_message)
|
||||
mock_create_ticket = mocker.patch("app.celery.broadcast_message_tasks.zendesk_client.create_ticket")
|
||||
@@ -117,7 +127,7 @@ def test_send_broadcast_event_creates_zendesk_p1(mocker, notify_api, sample_broa
|
||||
|
||||
assert str(broadcast_message.id) in zendesk_args['message']
|
||||
assert 'channel severe' in zendesk_args['message']
|
||||
assert "areas ['wd20-S13002775', 'wd20-S13002773']" in zendesk_args['message']
|
||||
assert f"areas {expected_message}" in zendesk_args['message']
|
||||
# the start of the content from the broadcast template
|
||||
assert "Dear Sir/Madam" in zendesk_args['message']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user