Improvements to the tests.

Update AuthError with a to_dict_v2 method.
This commit is contained in:
Rebecca Law
2016-11-01 10:33:34 +00:00
parent a358f3cb3a
commit 482d10545b
8 changed files with 58 additions and 46 deletions

View File

@@ -56,12 +56,13 @@ post_sms_response = {
}
def create_post_sms_response_from_notification(notification, content):
def create_post_sms_response_from_notification(notification, body, from_number, url_root):
return {"id": notification.id,
"reference": None, # not yet implemented
"content": content,
"uri": "v2/notifications/{}".format(notification.id),
"content": {'body': body,
'from_number': from_number},
"uri": "{}/v2/notifications/{}".format(url_root, str(notification.id)),
"template": {"id": notification.template_id,
"version": notification.template_version,
"uri": "v2/templates/{}".format(notification.template_id)}
"uri": "{}/v2/templates/{}".format(url_root, str(notification.template_id))}
}

View File

@@ -1,4 +1,4 @@
from flask import request, jsonify
from flask import request, jsonify, current_app
from sqlalchemy.orm.exc import NoResultFound
from app import api_user
@@ -38,7 +38,8 @@ def post_sms_notification():
api_key_id=api_user.id,
key_type=api_user.key_type)
send_notification_to_queue(notification, service.research_mode)
resp = create_post_sms_response_from_notification(notification, content)
resp = create_post_sms_response_from_notification(notification, content, service.sms_sender, request.url_root)
return jsonify(resp), 201
@@ -67,4 +68,4 @@ def __validate_template(form, service):
check_template_is_active(template)
template_with_content = create_content_for_notification(template, form.get('personalisation', {}))
check_sms_content_char_count(template_with_content.replaced_content_count)
return template, template_with_content.replaced_content_count
return template, template_with_content.content