Merge pull request #3893 from alphagov/allow-provider-all-channels

Allow setting provider for any channel
This commit is contained in:
David McDonald
2021-06-03 09:36:43 +01:00
committed by GitHub
7 changed files with 162 additions and 95 deletions

View File

@@ -325,15 +325,15 @@ def test_some_broadcast_tour_pages_show_service_name(
False,
'test',
'all',
'.navigation-service-type.navigation-service-type--live',
'service one Test (all networks) Switch service',
'Test (all networks)',
'.navigation-service-type.navigation-service-type--test',
'service one Test Switch service',
'Test',
),
(
False,
'test',
'vodafone',
'.navigation-service-type.navigation-service-type--live',
'.navigation-service-type.navigation-service-type--test',
'service one Test (Vodafone) Switch service',
'Test (Vodafone)',
),
@@ -345,9 +345,25 @@ def test_some_broadcast_tour_pages_show_service_name(
'service one Government Switch service',
'Government',
),
(
False,
'government',
'vodafone',
'.navigation-service-type.navigation-service-type--government',
'service one Government (Vodafone) Switch service',
'Government (Vodafone)',
),
(
False,
'severe',
'vodafone',
'.navigation-service-type.navigation-service-type--live',
'service one Live (Vodafone) Switch service',
'Live (Vodafone)',
),
)
)
def test_broadcast_service_shows_live_or_training(
def test_broadcast_service_shows_channel_settings(
client_request,
service_one,
mock_get_no_broadcast_messages,

View File

@@ -163,9 +163,9 @@ def test_platform_admin_sees_only_relevant_settings_for_broadcast_service(
SERVICE_ONE_ID,
users=[api_user_active['id']],
permissions=['broadcast'],
restricted=True,
organisation_id=ORGANISATION_ID,
contact_link='contact_us@gov.uk',
broadcast_channel="severe",
)
mocker.patch('app.service_api_client.get_service', return_value={'data': service_one})
@@ -186,7 +186,7 @@ def test_platform_admin_sees_only_relevant_settings_for_broadcast_service(
'Label Value Action',
'Notes None Change the notes for the service',
'Email authentication Off Change your settings for Email authentication',
'Emergency alerts Training Change your settings for emergency alerts',
'Emergency alerts Off Change your settings for emergency alerts',
]
assert len(rows) == len(expected_rows)
@@ -203,8 +203,11 @@ def test_platform_admin_sees_only_relevant_settings_for_broadcast_service(
(True, "training", "test", "all", "Training"),
(True, "live", "test", "ee", "Test (EE)"),
(True, "live", "test", "three", "Test (Three)"),
(True, "live", "test", "all", "Test (all networks)"),
(True, "live", "test", "all", "Test"),
(True, "live", "severe", "all", "Live"),
(True, "live", "severe", "three", "Live (Three)"),
(True, "live", "government", "all", "Government"),
(True, "live", "government", "three", "Government (Three)"),
]
)
def test_platform_admin_sees_correct_description_of_broadcast_service_setting(
@@ -239,8 +242,8 @@ def test_platform_admin_sees_correct_description_of_broadcast_service_setting(
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
broadcast_setting_row = page.find(string=re.compile("Emergency alerts")).find_parent('tr')
broadcast_setting_description = broadcast_setting_row.select('td')[1].text.strip()
assert broadcast_setting_description == expected_text
broadcast_setting_description = broadcast_setting_row.select('td')[1].text
assert normalize_spaces(broadcast_setting_description) == expected_text
def test_no_go_live_link_for_service_without_organisation(
@@ -5605,17 +5608,17 @@ def test_get_service_set_broadcast_account_type_has_radio_selected_for_broadcast
(
'live-test',
'.service_set_broadcast_network',
{},
{'broadcast_channel': 'test'},
),
(
'live-severe',
'.service_confirm_broadcast_account_type',
{'account_type': 'live-severe'},
'.service_set_broadcast_network',
{'broadcast_channel': 'severe'},
),
(
'live-government',
'.service_confirm_broadcast_account_type',
{'account_type': 'live-government'},
'.service_set_broadcast_network',
{'broadcast_channel': 'government'},
),
]
)
@@ -5656,13 +5659,17 @@ def test_get_service_set_broadcast_channel_redirects(
"live",
"severe",
"all",
[],
[
("All networks", "live-severe"),
],
),
(
"live",
"government",
"all",
[],
[
("All networks", "live-government"),
],
),
(
"live",
@@ -5708,6 +5715,24 @@ def test_get_service_set_broadcast_channel_redirects(
("Vodafone", "live-test-vodafone"),
],
),
(
"live",
"severe",
"vodafone",
[
("A single network", ""),
("Vodafone", "live-severe-vodafone"),
],
),
(
"live",
"government",
"vodafone",
[
("A single network", ""),
("Vodafone", "live-government-vodafone"),
],
),
]
)
def test_get_service_set_broadcast_network_has_radio_selected(
@@ -5732,6 +5757,7 @@ def test_get_service_set_broadcast_network_has_radio_selected(
page = client_request.get(
'main.service_set_broadcast_network',
service_id=SERVICE_ONE_ID,
broadcast_channel=broadcast_channel,
)
assert [
@@ -5744,40 +5770,38 @@ def test_get_service_set_broadcast_network_has_radio_selected(
@pytest.mark.parametrize(
'data, expected_result',
'broadcast_channel, provider, choice_type',
(
(
{'network_variant': 'live-test'},
'live-test'
),
(
{'network_variant': '', 'network': 'live-test-ee'},
'live-test-ee'
),
(
{'network_variant': '', 'network': 'live-test-o2'},
'live-test-o2'
),
(
{'network_variant': '', 'network': 'live-test-three'},
'live-test-three'
),
(
{'network_variant': '', 'network': 'live-test-vodafone'},
'live-test-vodafone'
),
('severe', '', 'network_variant'),
('government', '', 'network_variant'),
('test', '', 'network_variant'),
('test', 'o2', 'network'),
('test', 'ee', 'network'),
('test', 'three', 'network'),
('test', 'vodafone', 'network'),
('government', 'vodafone', 'network'),
('severe', 'vodafone', 'network'),
),
)
def test_post_service_set_broadcast_network(
client_request,
platform_admin_user,
data,
expected_result,
broadcast_channel,
provider,
choice_type,
):
if choice_type == 'network_variant':
expected_result = f'live-{broadcast_channel}'
data = {'network_variant': expected_result}
else:
expected_result = f'live-{broadcast_channel}-{provider}'
data = {'network_variant': '', 'network': expected_result}
client_request.login(platform_admin_user)
client_request.post(
'main.service_set_broadcast_network',
service_id=SERVICE_ONE_ID,
broadcast_channel=broadcast_channel,
_data=data,
_expected_status=302,
_expected_redirect=url_for(
@@ -5796,16 +5820,19 @@ def test_post_service_set_broadcast_network(
{'network_variant': ''}, # Missing choice of MNO
),
)
@pytest.mark.parametrize('broadcast_channel', ['government', 'severe', 'test'])
def test_post_service_set_broadcast_network_makes_you_choose(
client_request,
platform_admin_user,
mocker,
data,
broadcast_channel
):
client_request.login(platform_admin_user)
page = client_request.post(
'main.service_set_broadcast_network',
service_id=SERVICE_ONE_ID,
broadcast_channel=broadcast_channel,
_data=data,
_expected_status=200,
)
@@ -5846,7 +5873,7 @@ def test_post_service_set_broadcast_network_makes_you_choose(
'this service.',
]),
('live-test', [
'Test (all networks)',
'Test',
'Members of the public who have switched on the test '
'channel on their phones will receive alerts sent from '
'this service.',
@@ -5856,11 +5883,21 @@ def test_post_service_set_broadcast_network_makes_you_choose(
'Members of the public will receive alerts sent from this '
'service.',
]),
('live-severe-vodafone', [
'Live (Vodafone)',
'Members of the public will receive alerts sent from this '
'service.',
]),
('live-government', [
'Government',
'Members of the public will receive alerts sent from this '
'service, even if theyve opted out.'
]),
('live-government-vodafone', [
'Government (Vodafone)',
'Members of the public will receive alerts sent from this '
'service, even if theyve opted out.'
]),
]
)
def test_post_service_set_broadcast_account_type_confirmation_page(
@@ -5925,14 +5962,15 @@ def test_post_service_set_broadcast_account_type_posts_data_to_api_and_redirects
)
@pytest.mark.parametrize('endpoint, expected_error', (
('main.service_set_broadcast_channel', 'Error: Select mode or channel'),
('main.service_set_broadcast_network', 'Error: Select a mobile network'),
@pytest.mark.parametrize('endpoint, extra_args, expected_error', (
('main.service_set_broadcast_channel', {}, 'Error: Select mode or channel'),
('main.service_set_broadcast_network', {'broadcast_channel': 'government'}, 'Error: Select a mobile network'),
))
def test_post_service_set_broadcast_account_type_shows_errors_if_no_radio_selected(
platform_admin_client,
mocker,
endpoint,
extra_args,
expected_error,
):
set_service_broadcast_settings_mock = mocker.patch('app.service_api_client.set_service_broadcast_settings')
@@ -5942,6 +5980,7 @@ def test_post_service_set_broadcast_account_type_shows_errors_if_no_radio_select
url_for(
endpoint,
service_id=SERVICE_ONE_ID,
**extra_args
)
)
assert response.status_code == 200