mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-11 10:28:55 -04:00
Allow service.allowed_broadcast_provider to be "all"
We want to replace the value `None` for service.allowed_broadcast_provider with the value of "all". As a first step, we need to allow both values. Once notifications-admin has been changed to pass through "all" and all the data in the database has been updated, we can update the code to stop supporting both values.
This commit is contained in:
@@ -64,7 +64,7 @@ def set_broadcast_service_type(service, service_mode, broadcast_channel, provide
|
||||
db.session.add(service)
|
||||
|
||||
|
||||
def insert_or_update_service_broadcast_settings(service, channel, provider_restriction=None):
|
||||
def insert_or_update_service_broadcast_settings(service, channel, provider_restriction="all"):
|
||||
if not service.service_broadcast_settings:
|
||||
settings = ServiceBroadcastSettings()
|
||||
settings.service = service
|
||||
|
||||
+5
-1
@@ -560,7 +560,8 @@ class Service(db.Model, Versioned):
|
||||
|
||||
def get_available_broadcast_providers(self):
|
||||
# There may be future checks here if we add, for example, platform admin level provider killswitches.
|
||||
if self.allowed_broadcast_provider:
|
||||
# NOTE: We are in the middle of changing the value for all allowed_broadcast_provider from `None`to "all"
|
||||
if self.allowed_broadcast_provider and self.allowed_broadcast_provider != ALL_BROADCAST_PROVIDERS:
|
||||
return [x for x in current_app.config['ENABLED_CBCS'] if x == self.allowed_broadcast_provider]
|
||||
else:
|
||||
return current_app.config['ENABLED_CBCS']
|
||||
@@ -2488,6 +2489,9 @@ class BroadcastProvider:
|
||||
PROVIDERS = [EE, VODAFONE, THREE, O2]
|
||||
|
||||
|
||||
ALL_BROADCAST_PROVIDERS = 'all'
|
||||
|
||||
|
||||
class BroadcastProviderMessageStatus:
|
||||
TECHNICAL_FAILURE = 'technical-failure' # Couldn’t send (cbc proxy 5xx/4xx)
|
||||
SENDING = 'sending' # Sent to cbc, awaiting response
|
||||
|
||||
@@ -6,7 +6,7 @@ service_broadcast_settings_schema = {
|
||||
"properties": {
|
||||
"broadcast_channel": {"enum": ["test", "severe"]},
|
||||
"service_mode": {"enum": ["training", "live"]},
|
||||
"provider_restriction": {"enum": [None, "three", "o2", "vodafone", "ee"]}
|
||||
"provider_restriction": {"enum": [None, "three", "o2", "vodafone", "ee", "all"]}
|
||||
},
|
||||
"required": ["broadcast_channel", "service_mode", "provider_restriction"]
|
||||
}
|
||||
|
||||
@@ -30,7 +30,14 @@ from tests.app.db import (
|
||||
from tests.conftest import set_config
|
||||
|
||||
|
||||
def test_send_broadcast_event_queues_up_for_active_providers(mocker, notify_api, sample_broadcast_service):
|
||||
@pytest.mark.parametrize('available_provider', [None, 'all'])
|
||||
def test_send_broadcast_event_queues_up_for_active_providers(
|
||||
mocker,
|
||||
notify_api,
|
||||
sample_broadcast_service,
|
||||
available_provider,
|
||||
):
|
||||
sample_broadcast_service.allowed_broadcast_provider = available_provider
|
||||
template = create_template(sample_broadcast_service, BROADCAST_TYPE)
|
||||
broadcast_message = create_broadcast_message(template, status=BroadcastStatusType.BROADCASTING)
|
||||
event = create_broadcast_event(broadcast_message)
|
||||
|
||||
@@ -290,6 +290,8 @@ def test_get_service_by_id(admin_request, sample_service):
|
||||
|
||||
|
||||
@pytest.mark.parametrize('broadcast_channel,allowed_broadcast_provider', (
|
||||
('test', 'all'),
|
||||
('severe', 'all'),
|
||||
('test', None),
|
||||
('severe', None),
|
||||
('test', 'ee'),
|
||||
@@ -4018,7 +4020,7 @@ def test_set_as_broadcast_service_rejects_if_no_service_mode(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('provider', [None, "three", "ee", "vodafone", "o2"])
|
||||
@pytest.mark.parametrize('provider', [None, "all", "three", "ee", "vodafone", "o2"])
|
||||
def test_set_as_broadcast_service_sets_mobile_provider_restriction(
|
||||
admin_request, sample_service, broadcast_organisation, provider
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user