mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 17:01:35 -05:00
Merge pull request #2453 from alphagov/update-response-for-duplicate-domains
Return a useful message if the domain is a duplicate.
This commit is contained in:
@@ -34,6 +34,9 @@ def handle_integrity_error(exc):
|
||||
if 'ix_organisation_name' in str(exc):
|
||||
return jsonify(result="error",
|
||||
message="Organisation name already exists"), 400
|
||||
if 'domain_organisation_id_fkey' in str(exc):
|
||||
return jsonify(result='error',
|
||||
message='Domain already exists'), 400
|
||||
|
||||
current_app.logger.exception(exc)
|
||||
return jsonify(result='error', message="Internal server error"), 500
|
||||
|
||||
@@ -326,6 +326,22 @@ def test_post_update_organisation_gives_404_status_if_org_does_not_exist(admin_r
|
||||
assert not organisation
|
||||
|
||||
|
||||
def test_post_update_organisation_returns_400_if_domain_is_duplicate(admin_request, notify_db_session):
|
||||
org = create_organisation()
|
||||
create_domain('same.com', org.id)
|
||||
|
||||
data = {'domains': ['new.com', 'same.com']}
|
||||
|
||||
response = admin_request.post(
|
||||
'organisation.update_organisation',
|
||||
_data=data,
|
||||
organisation_id='31d42ce6-3dac-45a7-95cb-94423d5ca03c',
|
||||
_expected_status=400
|
||||
)
|
||||
|
||||
assert response['message'] == 'Domain already exists'
|
||||
|
||||
|
||||
def test_post_link_service_to_organisation(admin_request, sample_service, sample_organisation):
|
||||
data = {
|
||||
'service_id': str(sample_service.id)
|
||||
|
||||
Reference in New Issue
Block a user