From dbe914f401dbd4bdf4b858d9eade936270c30308 Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Mon, 22 Feb 2016 14:32:41 +0000 Subject: [PATCH] Changed error format on template subject duplication error --- app/template/rest.py | 2 +- tests/app/template/test_rest.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/template/rest.py b/app/template/rest.py index ebc61e572..a51031654 100644 --- a/app/template/rest.py +++ b/app/template/rest.py @@ -44,7 +44,7 @@ def create_template(service_id): message = "Failed to create template" if "templates_subject_key" in str(ex): message = 'Duplicate template subject' - return jsonify(result="error", message=message), 400 + return jsonify(result="error", message=[{'subject': message}]), 400 return jsonify(result="error", message=message), 500 return jsonify(data=template_schema.dump(new_template).data), 201 diff --git a/tests/app/template/test_rest.py b/tests/app/template/test_rest.py index fca1bc272..0ba8c0a68 100644 --- a/tests/app/template/test_rest.py +++ b/tests/app/template/test_rest.py @@ -193,7 +193,7 @@ def test_must_have_a_uniqe_subject_on_an_email_template(notify_api, sample_servi assert response.status_code == 400 json_resp = json.loads(response.get_data(as_text=True)) assert json_resp['result'] == 'error' - assert json_resp['message'] == 'Duplicate template subject' + assert json_resp['message'][0]['subject'] == 'Duplicate template subject' def test_should_be_able_to_update_a_template(notify_api, sample_service):