- Change update service name to check that the name/email_from is unique across all services.

- This is done using a new endpoint in the api.
- Removed the AddServiceForm in favor or using the ServiceNameForm
- Removed ServiceApiClient.find_all_service_email_from
This commit is contained in:
Rebecca Law
2017-08-09 16:52:10 +01:00
parent 14be8dc463
commit 9b9c6d75dc
6 changed files with 29 additions and 37 deletions

View File

@@ -227,7 +227,7 @@ def test_should_redirect_after_change_service_name(
logged_in_client,
service_one,
mock_update_service,
mock_get_services,
mock_service_name_is_unique
):
response = logged_in_client.post(
url_for('main.service_name_change', service_id=service_one['id']),
@@ -237,7 +237,7 @@ def test_should_redirect_after_change_service_name(
settings_url = url_for(
'main.service_name_change_confirm', service_id=service_one['id'], _external=True)
assert settings_url == response.location
assert mock_get_services.called
assert mock_service_name_is_unique.called
def test_show_restricted_service(
@@ -302,11 +302,9 @@ def test_switch_service_to_restricted(
def test_should_not_allow_duplicate_names(
logged_in_client,
mocker,
mock_service_name_is_not_unique,
service_one,
):
mocker.patch('app.service_api_client.find_all_service_email_from',
return_value=['service_one', 'service.two'])
service_id = service_one['id']
response = logged_in_client.post(
url_for('main.service_name_change', service_id=service_id),
@@ -315,7 +313,7 @@ def test_should_not_allow_duplicate_names(
assert response.status_code == 200
resp_data = response.get_data(as_text=True)
assert 'This service name is already in use' in resp_data
app.service_api_client.find_all_service_email_from.assert_called_once_with()
app.service_api_client.is_service_name_unique.assert_called_once_with('SErvICE TWO', 'service.two')
def test_should_show_service_name_confirmation(