mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
Merge pull request #2459 from alphagov/update-response-for-duplicate-domains
The previous PR added a error handler for the wrong db exception.
This commit is contained in:
@@ -34,7 +34,7 @@ def handle_integrity_error(exc):
|
|||||||
if 'ix_organisation_name' in str(exc):
|
if 'ix_organisation_name' in str(exc):
|
||||||
return jsonify(result="error",
|
return jsonify(result="error",
|
||||||
message="Organisation name already exists"), 400
|
message="Organisation name already exists"), 400
|
||||||
if 'domain_organisation_id_fkey' in str(exc):
|
if 'duplicate key value violates unique constraint "domain_pkey"' in str(exc):
|
||||||
return jsonify(result='error',
|
return jsonify(result='error',
|
||||||
message='Domain already exists'), 400
|
message='Domain already exists'), 400
|
||||||
|
|
||||||
|
|||||||
@@ -328,6 +328,7 @@ def test_post_update_organisation_gives_404_status_if_org_does_not_exist(admin_r
|
|||||||
|
|
||||||
def test_post_update_organisation_returns_400_if_domain_is_duplicate(admin_request, notify_db_session):
|
def test_post_update_organisation_returns_400_if_domain_is_duplicate(admin_request, notify_db_session):
|
||||||
org = create_organisation()
|
org = create_organisation()
|
||||||
|
org2 = create_organisation(name='Second org')
|
||||||
create_domain('same.com', org.id)
|
create_domain('same.com', org.id)
|
||||||
|
|
||||||
data = {'domains': ['new.com', 'same.com']}
|
data = {'domains': ['new.com', 'same.com']}
|
||||||
@@ -335,7 +336,7 @@ def test_post_update_organisation_returns_400_if_domain_is_duplicate(admin_reque
|
|||||||
response = admin_request.post(
|
response = admin_request.post(
|
||||||
'organisation.update_organisation',
|
'organisation.update_organisation',
|
||||||
_data=data,
|
_data=data,
|
||||||
organisation_id='31d42ce6-3dac-45a7-95cb-94423d5ca03c',
|
organisation_id=org2.id,
|
||||||
_expected_status=400
|
_expected_status=400
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user