mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 17:38:50 -04:00
Improve coverage of resume service tests
This makes the tests consistent with those for suspend / archive, logging in with different users to make it clearer who can/not do this action in the backend. Note that we think this functionality may be too permissive [1], so we may restrict it in a future PR. [1]: https://github.com/alphagov/notifications-admin/pull/3959#issuecomment-878291295
This commit is contained in:
@@ -4275,27 +4275,42 @@ def test_cant_suspend_inactive_service(
|
||||
assert 'Suspend service' not in {a.text for a in page.find_all('a', class_='button')}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('user', (
|
||||
create_platform_admin_user(),
|
||||
create_active_user_with_permissions(),
|
||||
pytest.param(create_active_user_no_settings_permission(), marks=pytest.mark.xfail),
|
||||
))
|
||||
def test_resume_service_after_confirm(
|
||||
platform_admin_client,
|
||||
service_one,
|
||||
single_reply_to_email_address,
|
||||
single_letter_contact_block,
|
||||
mock_get_organisation,
|
||||
mocker,
|
||||
mock_get_inbound_number_for_service,
|
||||
user,
|
||||
service_one,
|
||||
client_request,
|
||||
):
|
||||
service_one['active'] = False
|
||||
mocked_fn = mocker.patch('app.service_api_client.post', return_value=service_one)
|
||||
mock_api = mocker.patch('app.service_api_client.post')
|
||||
|
||||
response = platform_admin_client.post(url_for('main.resume_service', service_id=service_one['id']))
|
||||
client_request.login(user)
|
||||
client_request.post(
|
||||
'main.resume_service',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_expected_redirect=url_for(
|
||||
'main.service_settings',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_external=True
|
||||
)
|
||||
)
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('main.service_settings', service_id=service_one['id'], _external=True)
|
||||
assert mocked_fn.call_args == call('/service/{}/resume'.format(service_one['id']), data=None)
|
||||
assert mock_api.called_once_with('/service/{}/resume'.format(SERVICE_ONE_ID), data=None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('user', (
|
||||
create_platform_admin_user(),
|
||||
create_active_user_with_permissions(),
|
||||
pytest.param(create_active_user_no_settings_permission(), marks=pytest.mark.xfail),
|
||||
))
|
||||
def test_resume_service_prompts_user(
|
||||
platform_admin_client,
|
||||
client_request,
|
||||
user,
|
||||
service_one,
|
||||
single_reply_to_email_address,
|
||||
single_letter_contact_block,
|
||||
@@ -4304,15 +4319,14 @@ def test_resume_service_prompts_user(
|
||||
mock_get_service_settings_page_common,
|
||||
):
|
||||
service_one['active'] = False
|
||||
mocked_fn = mocker.patch('app.service_api_client.post')
|
||||
mock_api = mocker.patch('app.service_api_client.post')
|
||||
|
||||
response = platform_admin_client.get(url_for('main.resume_service', service_id=service_one['id']))
|
||||
client_request.login(user)
|
||||
page = client_request.get('main.resume_service', service_id=service_one['id'])
|
||||
|
||||
assert response.status_code == 200
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
assert 'This will resume the service. New api key are required for this service to use the API.' in \
|
||||
page.find('div', class_='banner-dangerous').text
|
||||
assert mocked_fn.called is False
|
||||
assert mock_api.called is False
|
||||
|
||||
|
||||
def test_cant_resume_active_service(
|
||||
|
||||
Reference in New Issue
Block a user