mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-16 20:48:37 -04:00
Store the event field from CAP XML broadcasts
We don’t store everything that comes in the CAP XML when someone creates a broadcast via the API. One thing we do store is `<identifier>` (in a column called `reference`) which is a unique (to the external system) identifier for the broadcast. We show this in the front end instead of the template name, because broadcasts created from the API don’t use templates. However this ID isn’t very friendly – the Environment Agency just supply a UUID. The Environment Agency also populate the `<event>` field with some human readable text, for example: > 013 Issue Severe Flood Warning EA (013 is an area code which will be meaningful to the Flood Warning Service team) We should show this in the UI instead of the reference. The first step towards this is storing it in the database and returning it in the REST endpoints. Later we can have the admin app prefer `cap_event` over `reference`, where `cap_event` is present. We can’t backfill this data because we don’t keep a copy of the original XML. Seems like `<event>` is a mandatory property of `<info>`, so we don’t need to worry about the field being missing (`<info>` is optional in CAP but we require it because it contains stuff like the areas which we need in order to send out the broadcast`). *** https://www.pivotaltracker.com/story/show/176927060
This commit is contained in:
@@ -91,6 +91,26 @@ def test_get_broadcast_message_without_template(
|
||||
assert response['personalisation'] is None
|
||||
|
||||
|
||||
def test_get_broadcast_message_with_event(
|
||||
admin_request,
|
||||
sample_broadcast_service
|
||||
):
|
||||
bm = create_broadcast_message(
|
||||
service=sample_broadcast_service,
|
||||
content='emergency broadcast content',
|
||||
cap_event='001 example event',
|
||||
)
|
||||
|
||||
response = admin_request.get(
|
||||
'broadcast_message.get_broadcast_message',
|
||||
service_id=sample_broadcast_service.id,
|
||||
broadcast_message_id=bm.id,
|
||||
_expected_status=200
|
||||
)
|
||||
|
||||
assert response['cap_event'] == '001 example event'
|
||||
|
||||
|
||||
def test_get_broadcast_message_404s_if_message_doesnt_exist(admin_request, sample_broadcast_service):
|
||||
err = admin_request.get(
|
||||
'broadcast_message.get_broadcast_message',
|
||||
@@ -255,6 +275,7 @@ def test_create_broadcast_message_can_be_created_from_content(admin_request, sam
|
||||
assert response['content'] == 'Some content\n€ŷŵ~\n\'\'""---'
|
||||
assert response['reference'] == 'abc123'
|
||||
assert response['template_id'] is None
|
||||
assert response['cap_event'] is None
|
||||
|
||||
|
||||
def test_create_broadcast_message_400s_if_content_and_template_provided(
|
||||
|
||||
Reference in New Issue
Block a user