mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-28 18:24:00 -04:00
Merge pull request #4052 from alphagov/broadcast-event-field
Prefer `event` to `reference` when referring to an alert
This commit is contained in:
@@ -162,7 +162,7 @@ class BroadcastMessage(JSONModel):
|
||||
def reference(self):
|
||||
if self.template_id:
|
||||
return self._dict['template_name']
|
||||
return self._dict['reference']
|
||||
return self._dict['cap_event'] or self._dict['reference']
|
||||
|
||||
@property
|
||||
def template(self):
|
||||
|
||||
@@ -684,6 +684,7 @@ def broadcast_message_json(
|
||||
simple_polygons=None,
|
||||
content=None,
|
||||
reference=None,
|
||||
cap_event=None,
|
||||
template_name='Example template',
|
||||
):
|
||||
return {
|
||||
@@ -696,6 +697,7 @@ def broadcast_message_json(
|
||||
'template_name': template_name,
|
||||
'content': content or 'This is a test',
|
||||
'reference': reference,
|
||||
'cap_event': cap_event,
|
||||
|
||||
'personalisation': {},
|
||||
'areas': areas or {
|
||||
|
||||
@@ -1866,12 +1866,26 @@ def test_view_pending_broadcast(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('extra_broadcast_json_fields, expected_banner_text', (
|
||||
({'reference': 'ABC123'}, (
|
||||
'Test User Create Broadcasts Permission wants to broadcast ABC123 '
|
||||
'No phones will get this alert. '
|
||||
'Start broadcasting now Reject this alert'
|
||||
)),
|
||||
({'cap_event': 'Severe flood warning', 'reference': 'ABC123'}, (
|
||||
'Test User Create Broadcasts Permission wants to broadcast Severe flood warning '
|
||||
'No phones will get this alert. '
|
||||
'Start broadcasting now Reject this alert'
|
||||
)),
|
||||
))
|
||||
def test_view_pending_broadcast_without_template(
|
||||
mocker,
|
||||
client_request,
|
||||
service_one,
|
||||
fake_uuid,
|
||||
active_user_approve_broadcasts_permission,
|
||||
extra_broadcast_json_fields,
|
||||
expected_banner_text,
|
||||
):
|
||||
broadcast_creator = create_active_user_create_broadcasts_permissions(with_unique_id=True)
|
||||
mocker.patch(
|
||||
@@ -1883,8 +1897,8 @@ def test_view_pending_broadcast_without_template(
|
||||
created_by_id=broadcast_creator['id'],
|
||||
finishes_at=None,
|
||||
status='pending-approval',
|
||||
reference='No template test',
|
||||
content='Uh-oh',
|
||||
**extra_broadcast_json_fields,
|
||||
),
|
||||
)
|
||||
client_request.login(active_user_approve_broadcasts_permission)
|
||||
@@ -1902,11 +1916,8 @@ def test_view_pending_broadcast_without_template(
|
||||
|
||||
assert (
|
||||
normalize_spaces(page.select_one('.banner').text)
|
||||
) == (
|
||||
'Test User Create Broadcasts Permission wants to broadcast No template test '
|
||||
'No phones will get this alert. '
|
||||
'Start broadcasting now Reject this alert'
|
||||
)
|
||||
) == expected_banner_text
|
||||
|
||||
assert (
|
||||
normalize_spaces(page.select_one('.broadcast-message-wrapper').text)
|
||||
) == (
|
||||
|
||||
Reference in New Issue
Block a user