From e6d03ec6f8c94c59e67bdf51ea9abff3b03669d9 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 15 May 2019 16:16:23 +0100 Subject: [PATCH] Check that users have to choose an org type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we can’t guess a user’s organisation then they have to choose what type of organisation they work for when they add a new service. This commit adds a test to make sure they can’t just click the green button and proceed without picking one. --- tests/app/main/views/test_add_service.py | 31 +++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/app/main/views/test_add_service.py b/tests/app/main/views/test_add_service.py index ba41c1ad4..e6860cf2f 100644 --- a/tests/app/main/views/test_add_service.py +++ b/tests/app/main/views/test_add_service.py @@ -3,7 +3,7 @@ from flask import session, url_for from app.utils import is_gov_user from tests import organisation_json -from tests.conftest import mock_get_organisation_by_domain +from tests.conftest import mock_get_organisation_by_domain, normalize_spaces def test_non_gov_user_cannot_see_add_service_button( @@ -128,6 +128,35 @@ def test_should_add_service_and_redirect_to_tour_when_no_services( mock_create_or_update_free_sms_fragment_limit.assert_called_once_with(101, sms_limit) +def test_add_service_has_to_choose_org_type( + mocker, + client_request, + mock_create_service, + mock_create_service_template, + mock_get_services_with_no_services, + api_user_active, + mock_create_or_update_free_sms_fragment_limit, + mock_get_all_email_branding, +): + mocker.patch( + 'app.organisations_client.get_organisation_by_domain', + return_value=None, + ) + page = client_request.post( + 'main.add_service', + _data={ + 'name': 'testing the post', + }, + _expected_status=200, + ) + assert normalize_spaces(page.select_one('.error-message').text) == ( + 'Not a valid choice' + ) + assert mock_create_service.called is False + assert mock_create_service_template.called is False + assert mock_create_or_update_free_sms_fragment_limit.called is False + + @pytest.mark.parametrize('email_address', ( 'test@nhs.net', 'test@nhs.uk',