From e4a5e3890a4e0a3e260742b5988d0cb20aa35fdf Mon Sep 17 00:00:00 2001 From: Adam Shimali Date: Mon, 4 Apr 2016 14:51:56 +0100 Subject: [PATCH] Corrected error message format --- app/template_statistics/rest.py | 4 ++-- tests/app/template_statistics/test_rest.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/template_statistics/rest.py b/app/template_statistics/rest.py index b935cdc06..3446d2623 100644 --- a/app/template_statistics/rest.py +++ b/app/template_statistics/rest.py @@ -24,9 +24,9 @@ def get_template_statistics_for_service(service_id): try: limit_days = int(request.args['limit_days']) except ValueError as e: - error = 'Limit days {} is not an integer'.format(request.args['limit_days']) + error = '{} is not an integer'.format(request.args['limit_days']) current_app.logger.error(error) - return jsonify(result="error", message=[error]), 400 + return jsonify(result="error", message={'limit_days': [error]}), 400 else: limit_days = None stats = dao_get_template_statistics_for_service(service_id, limit_days=limit_days) diff --git a/tests/app/template_statistics/test_rest.py b/tests/app/template_statistics/test_rest.py index 51826d90a..20c99ba67 100644 --- a/tests/app/template_statistics/test_rest.py +++ b/tests/app/template_statistics/test_rest.py @@ -133,4 +133,4 @@ def test_get_all_template_statistics_with_bad_limit_arg_returns_400(notify_api, assert response.status_code == 400 json_resp = json.loads(response.get_data(as_text=True)) assert json_resp['result'] == 'error' - assert json_resp['message'] == ['Limit days blurk is not an integer'] + assert json_resp['message'] == {'limit_days': ['blurk is not an integer']}