mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 22:42:28 -05:00
Use service setting to pick broadcast channel
This falls back to the "test" channel if they do not have a ServiceBroadcastSetting for the moment, but we intend in future PRs to enforce that all broadcast services will have this property.
This commit is contained in:
@@ -9,7 +9,8 @@ from app.models import (
|
||||
BroadcastStatusType,
|
||||
BroadcastEventMessageType,
|
||||
BroadcastProviderMessageStatus,
|
||||
ServiceBroadcastProviderRestriction
|
||||
ServiceBroadcastProviderRestriction,
|
||||
ServiceBroadcastSettings,
|
||||
)
|
||||
from app.celery.broadcast_message_tasks import send_broadcast_event, send_broadcast_provider_message, trigger_link_test
|
||||
|
||||
@@ -159,6 +160,91 @@ def test_send_broadcast_provider_message_sends_data_correctly(
|
||||
)
|
||||
|
||||
|
||||
@freeze_time('2020-08-01 12:00')
|
||||
@pytest.mark.parametrize('provider,provider_capitalised', [
|
||||
['ee', 'EE'],
|
||||
['three', 'Three'],
|
||||
['o2', 'O2'],
|
||||
['vodafone', 'Vodafone'],
|
||||
])
|
||||
@pytest.mark.parametrize('channel', ['test', 'severe'])
|
||||
def test_send_broadcast_provider_message_uses_channel_set_on_broadcast_service(
|
||||
notify_db, mocker, sample_service, provider, provider_capitalised, channel
|
||||
):
|
||||
template = create_template(sample_service, BROADCAST_TYPE)
|
||||
broadcast_message = create_broadcast_message(
|
||||
template,
|
||||
areas={
|
||||
'areas': ['london', 'glasgow'],
|
||||
'simple_polygons': [
|
||||
[[50.12, 1.2], [50.13, 1.2], [50.14, 1.21]],
|
||||
[[-4.53, 55.72], [-3.88, 55.72], [-3.88, 55.96], [-4.53, 55.96]],
|
||||
],
|
||||
},
|
||||
status=BroadcastStatusType.BROADCASTING
|
||||
)
|
||||
event = create_broadcast_event(broadcast_message)
|
||||
notify_db.session.add(ServiceBroadcastSettings(service=sample_service, channel=channel))
|
||||
|
||||
mock_create_broadcast = mocker.patch(
|
||||
f'app.clients.cbc_proxy.CBCProxy{provider_capitalised}.create_and_send_broadcast',
|
||||
)
|
||||
|
||||
send_broadcast_provider_message(provider=provider, broadcast_event_id=str(event.id))
|
||||
|
||||
mock_create_broadcast.assert_called_once_with(
|
||||
identifier=mocker.ANY,
|
||||
message_number=mocker.ANY,
|
||||
headline='GOV.UK Notify Broadcast',
|
||||
description='this is an emergency broadcast message',
|
||||
areas=mocker.ANY,
|
||||
sent=mocker.ANY,
|
||||
expires=mocker.ANY,
|
||||
channel=channel,
|
||||
)
|
||||
|
||||
|
||||
@freeze_time('2020-08-01 12:00')
|
||||
@pytest.mark.parametrize('provider,provider_capitalised', [
|
||||
['ee', 'EE'],
|
||||
['three', 'Three'],
|
||||
['o2', 'O2'],
|
||||
['vodafone', 'Vodafone'],
|
||||
])
|
||||
def test_send_broadcast_provider_message_defaults_to_test_channel_if_no_service_broadcast_settings(
|
||||
notify_db, mocker, sample_service, provider, provider_capitalised
|
||||
):
|
||||
template = create_template(sample_service, BROADCAST_TYPE)
|
||||
broadcast_message = create_broadcast_message(
|
||||
template,
|
||||
areas={
|
||||
'areas': ['london', 'glasgow'],
|
||||
'simple_polygons': [
|
||||
[[50.12, 1.2], [50.13, 1.2], [50.14, 1.21]],
|
||||
[[-4.53, 55.72], [-3.88, 55.72], [-3.88, 55.96], [-4.53, 55.96]],
|
||||
],
|
||||
},
|
||||
status=BroadcastStatusType.BROADCASTING
|
||||
)
|
||||
event = create_broadcast_event(broadcast_message)
|
||||
mock_create_broadcast = mocker.patch(
|
||||
f'app.clients.cbc_proxy.CBCProxy{provider_capitalised}.create_and_send_broadcast',
|
||||
)
|
||||
|
||||
send_broadcast_provider_message(provider=provider, broadcast_event_id=str(event.id))
|
||||
|
||||
mock_create_broadcast.assert_called_once_with(
|
||||
identifier=mocker.ANY,
|
||||
message_number=mocker.ANY,
|
||||
headline='GOV.UK Notify Broadcast',
|
||||
description='this is an emergency broadcast message',
|
||||
areas=mocker.ANY,
|
||||
sent=mocker.ANY,
|
||||
expires=mocker.ANY,
|
||||
channel="test",
|
||||
)
|
||||
|
||||
|
||||
@freeze_time('2020-08-01 12:00')
|
||||
@pytest.mark.parametrize('provider,provider_capitalised', [
|
||||
['ee', 'EE'],
|
||||
|
||||
Reference in New Issue
Block a user