Allow excluding services from live services count

Adds a front end for:
https://github.com/alphagov/notifications-api/pull/2417

> Sometimes we have to make a few services for what really is one
> service, for example GOV.UK Pay and GOV.UK Pay Direct Debit. We also
> have our own test services which aren’t included in the count of live
> services. We currently count these as one service by not including
> them in the beta partners spreadsheet.
This commit is contained in:
Chris Hill-Scott
2019-03-25 14:46:42 +00:00
parent 0a4208ae36
commit 8fb576e60a
9 changed files with 102 additions and 2 deletions

View File

@@ -178,6 +178,7 @@ def service_json(
'volume_sms': 222222,
'volume_letter': 333333,
'consent_to_research': True,
'count_as_live': True,
}

View File

@@ -99,6 +99,7 @@ def mock_get_service_settings_page_common(
'Label Value Action',
'Live Off Change',
'Count in list of live services Yes Change',
'Organisation Org 1 Change',
'Organisation type Central Change',
'Free text message allowance 250,000 Change',
@@ -447,6 +448,65 @@ def test_switch_service_to_restricted(
)
@pytest.mark.parametrize('count_as_live, selected, labelled', (
(True, 'True', 'Yes'),
(False, 'False', 'No'),
))
def test_show_switch_service_to_count_as_live_page(
mocker,
client_request,
platform_admin_user,
mock_update_service,
count_as_live,
selected,
labelled,
):
mocker.patch(
'app.models.service.Service.count_as_live',
create=True,
new_callable=PropertyMock,
return_value=count_as_live,
)
client_request.login(platform_admin_user)
page = client_request.get(
'main.service_switch_count_as_live',
service_id=SERVICE_ONE_ID,
)
assert page.select_one('[checked]')['value'] == selected
assert page.select_one('label[for={}]'.format(
page.select_one('[checked]')['id']
)).text.strip() == labelled
@pytest.mark.parametrize('post_data, expected_persisted_value', (
('True', True),
('False', False),
))
def test_switch_service_to_count_as_live(
client_request,
platform_admin_user,
mock_update_service,
post_data,
expected_persisted_value,
):
client_request.login(platform_admin_user)
client_request.post(
'main.service_switch_count_as_live',
service_id=SERVICE_ONE_ID,
_data={'enabled': post_data},
_expected_status=302,
_expected_redirect=url_for(
'main.service_settings',
service_id=SERVICE_ONE_ID,
_external=True,
)
)
mock_update_service.assert_called_with(
SERVICE_ONE_ID,
count_as_live=expected_persisted_value,
)
def test_should_not_allow_duplicate_names(
logged_in_client,
mock_service_name_is_not_unique,