Merge pull request #1819 from alphagov/reduce-exception-when-id-not-found

Fix error message for invalid UUID
This commit is contained in:
Rebecca Law
2018-04-04 13:07:42 +01:00
committed by GitHub
3 changed files with 25 additions and 19 deletions

View File

@@ -210,15 +210,15 @@ def test_get_notification_by_id_invalid_id(client, sample_notification, id):
path='/v2/notifications/{}'.format(id),
headers=[('Content-Type', 'application/json'), auth_header])
assert response.status_code == 404
assert response.status_code == 400
assert response.headers['Content-type'] == 'application/json'
json_response = json.loads(response.get_data(as_text=True))
assert json_response == {
"message": "The requested URL was not found on the server. "
"If you entered the URL manually please check your spelling and try again.",
"result": "error"
}
assert json_response == {"errors": [
{"error": "ValidationError",
"message": "notification_id is not a valid UUID"
}],
"status_code": 400}
@pytest.mark.parametrize('created_at_month, estimated_delivery', [
@@ -628,7 +628,7 @@ def test_get_notifications_renames_letter_statuses(client, sample_letter_templat
)
auth_header = create_authorization_header(service_id=letter_noti.service_id)
response = client.get(
path=url_for('v2_notifications.get_notification_by_id', id=letter_noti.id),
path=url_for('v2_notifications.get_notification_by_id', notification_id=letter_noti.id),
headers=[('Content-Type', 'application/json'), auth_header]
)