Let the API return a 400 error message if the service name is a duplicate.
This commit is contained in:
Rebecca Law
2017-08-07 11:30:25 +01:00
parent 8b313ed8d1
commit 186202cc9d
5 changed files with 47 additions and 37 deletions

View File

@@ -173,6 +173,18 @@ def mock_create_service(mocker):
'app.service_api_client.create_service', side_effect=_create)
@pytest.fixture(scope='function')
def mock_create_duplicate_service(mocker):
def _create(service_name, message_limit, restricted, user_id, email_from):
json_mock = Mock(return_value={'message': {'name': ["Duplicate service name '{}'".format(service_name)]}})
resp_mock = Mock(status_code=400, json=json_mock)
http_error = HTTPError(response=resp_mock, message="Default message")
raise http_error
return mocker.patch(
'app.service_api_client.create_service', side_effect=_create)
@pytest.fixture(scope='function')
def mock_update_service(mocker):
def _update(service_id, **kwargs):