Updated test_validators to test the contents of the error messages.

Added some tests to the test_post_notifications.
Added a errorhandler for AuthErrors.

This endpoint is not being used anywhere, however there is some common code being used in the v1 post endpoint. The only thing that may be affected is the error response, hopefully they are the same.
This commit is contained in:
Rebecca Law
2016-10-31 12:22:26 +00:00
parent 8cf2fc72a8
commit fc298367c5
7 changed files with 120 additions and 42 deletions

View File

@@ -16,14 +16,15 @@ def check_service_message_limit(key_type, service):
def check_template_is_for_notification_type(notification_type, template_type):
if notification_type != template_type:
raise BadRequestError(
message="{0} template is not suitable for {1} notification".format(template_type,
notification_type))
message = "{0} template is not suitable for {1} notification".format(template_type,
notification_type)
raise BadRequestError(fields=[{'template': message}], message=message)
def check_template_is_active(template):
if template.archived:
raise BadRequestError(message="Template has been deleted")
raise BadRequestError(fields=[{'template': 'Template has been deleted'}],
message="Template has been deleted")
def service_can_send_to_recipient(send_to, key_type, service):