raise 404 when unknown url

consistent with other endpoints.

also refactor of notification_schema to separate some fns to a different file
This commit is contained in:
Leo Hemsted
2017-07-20 15:23:46 +01:00
parent 9caf45451e
commit 79e33073c9
5 changed files with 55 additions and 56 deletions

View File

@@ -1,3 +1,4 @@
import uuid
from flask import url_for, json
@@ -145,7 +146,7 @@ def test_returns_a_429_limit_exceeded_if_rate_limit_exceeded(
{'service_permissions': [EMAIL_TYPE, SMS_TYPE]},
{'restricted': True}
])
def test_post_letter_notification_returns_400_if_not_allowed_to_send_notification(
def test_post_letter_notification_returns_403_if_not_allowed_to_send_notification(
client,
notify_db_session,
service_args
@@ -159,7 +160,7 @@ def test_post_letter_notification_returns_400_if_not_allowed_to_send_notificatio
}
error_json = letter_request(client, data, service_id=service.id, _expected_status=400)
assert error_json['status_code'] == 400
assert error_json['status_code'] == 403
assert error_json['errors'] == [
{'error': 'BadRequestError', 'message': 'Cannot send letters'}
]

View File

@@ -442,8 +442,6 @@ def test_post_notification_raises_bad_request_if_not_valid_notification_type(cli
data='{}',
headers=[('Content-Type', 'application/json'), auth_header]
)
assert response.status_code == 400
assert response.status_code == 404
error_json = json.loads(response.get_data(as_text=True))
assert error_json['errors'] == [
{'error': 'BadRequestError', 'message': 'Unknown notification type foo'}
]
assert 'The requested URL was not found on the server.' in error_json['message']