diff --git a/app/celery/broadcast_message_tasks.py b/app/celery/broadcast_message_tasks.py index 0713ec381..adce949d3 100644 --- a/app/celery/broadcast_message_tasks.py +++ b/app/celery/broadcast_message_tasks.py @@ -140,10 +140,6 @@ def send_broadcast_provider_message(self, broadcast_event_id, provider): for polygon in broadcast_event.transmitted_areas["simple_polygons"] ] - channel = "test" - if broadcast_event.service.broadcast_channel: - channel = broadcast_event.service.broadcast_channel - cbc_proxy_provider_client = cbc_proxy_client.get_proxy(provider) try: @@ -156,7 +152,7 @@ def send_broadcast_provider_message(self, broadcast_event_id, provider): areas=areas, sent=broadcast_event.sent_at_as_cap_datetime_string, expires=broadcast_event.transmitted_finishes_at_as_cap_datetime_string, - channel=channel + channel=broadcast_event.service.broadcast_channel ) elif broadcast_event.message_type == BroadcastEventMessageType.UPDATE: cbc_proxy_provider_client.update_and_send_broadcast( @@ -174,7 +170,7 @@ def send_broadcast_provider_message(self, broadcast_event_id, provider): # but we are relying on service channels changing almost never, and not mid incident # We may consider in the future, changing this such that we store the channel a broadcast was # sent on on the broadcast message itself and pick the value from there instead of the service - channel=channel + channel=broadcast_event.service.broadcast_channel ) elif broadcast_event.message_type == BroadcastEventMessageType.CANCEL: cbc_proxy_provider_client.cancel_broadcast( diff --git a/app/schemas.py b/app/schemas.py index f8b510f7b..41d487608 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -25,7 +25,7 @@ from notifications_utils.recipients import ( from app import ma from app import models -from app.models import ServicePermission, BROADCAST_TYPE +from app.models import ServicePermission from app.dao.permissions_dao import permission_dao from app.utils import DATETIME_FORMAT_NO_TIMEZONE, get_template_instance @@ -242,14 +242,7 @@ class ServiceSchema(BaseSchema, UUIDsAsStringsMixin): return service.allowed_broadcast_provider def _get_broadcast_channel(self, service): - # TODO: Once we've migrated data so that all broadcast services have `service.broadcast_channel` - # set then we can remove this logic and related tests and instead just return - # `service.broadcast_channel`. For the moment though, as we have some services with the broadcast - # permission that do not have a row in the service_broadcast_settings table, we need to hardcode - # this in here to give them a default that the admin app can use - if BROADCAST_TYPE in self.service_permissions(service): - return service.broadcast_channel if service.broadcast_channel else "test" - return None + return service.broadcast_channel def get_letter_logo_filename(self, service): return service.letter_branding and service.letter_branding.filename diff --git a/tests/app/celery/test_broadcast_message_tasks.py b/tests/app/celery/test_broadcast_message_tasks.py index 5d7cf0f39..28b39a270 100644 --- a/tests/app/celery/test_broadcast_message_tasks.py +++ b/tests/app/celery/test_broadcast_message_tasks.py @@ -203,47 +203,6 @@ def test_send_broadcast_provider_message_uses_channel_set_on_broadcast_service( ) -@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", - ) - - def test_send_broadcast_provider_message_works_if_we_retried_previously(mocker, sample_broadcast_service): template = create_template(sample_broadcast_service, BROADCAST_TYPE) broadcast_message = create_broadcast_message( diff --git a/tests/app/service/test_rest.py b/tests/app/service/test_rest.py index f64dd4613..d51a9effb 100644 --- a/tests/app/service/test_rest.py +++ b/tests/app/service/test_rest.py @@ -300,28 +300,6 @@ def test_get_service_by_id_for_broadcast_service_returns_broadcast_keys( assert json_resp['data']['broadcast_channel'] == broadcast_channel -def test_get_service_by_id_for_service_with_broadcast_permission_sets_channel_as_test_if_no_service_broadcast_settings( - admin_request, notify_db_session -): - service = create_service(service_permissions=[BROADCAST_TYPE]) - assert BROADCAST_TYPE in [p.permission for p in service.permissions] - assert service.broadcast_channel is None - - json_resp = admin_request.get('service.get_service_by_id', service_id=service.id) - assert json_resp['data']['id'] == str(service.id) - assert json_resp['data']['broadcast_channel'] == 'test' - - -def test_get_service_by_id_for_non_broadcast_service_sets_channel_as_none( - admin_request, sample_service -): - assert BROADCAST_TYPE not in [p.permission for p in sample_service.permissions] - - json_resp = admin_request.get('service.get_service_by_id', service_id=sample_service.id) - assert json_resp['data']['id'] == str(sample_service.id) - assert json_resp['data']['broadcast_channel'] is None - - @pytest.mark.parametrize('detailed', [True, False]) def test_get_service_by_id_returns_organisation_type(admin_request, sample_service, detailed): json_resp = admin_request.get('service.get_service_by_id', service_id=sample_service.id, detailed=detailed)