From aa823fd3bbe42ead475217e2a5b947a636cf63dd Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Wed, 5 Apr 2017 16:23:03 +0800 Subject: unify error message in TestAPI Change-Id: I994feb7bf340c9e48bebe9fdf3dc3a76bc254652 Signed-off-by: SerenaFeng --- .../testapi/opnfv_testapi/resources/result_handlers.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'utils/test/testapi/opnfv_testapi/resources/result_handlers.py') diff --git a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py b/utils/test/testapi/opnfv_testapi/resources/result_handlers.py index 3e78057ce..609c5ce20 100644 --- a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/result_handlers.py @@ -12,6 +12,7 @@ import httplib from bson import objectid +from opnfv_testapi.common import message from opnfv_testapi.common import raises from opnfv_testapi.resources import handlers from opnfv_testapi.resources import result_models @@ -30,7 +31,7 @@ class GenericResultHandler(handlers.GenericApiHandler): try: value = int(value) except: - raises.BadRequest('{} must be int'.format(key)) + raises.BadRequest(message.must_int(key)) return value def set_query(self): @@ -144,23 +145,21 @@ class ResultsCLHandler(GenericResultHandler): return {'name': data.pod_name} def pod_error(data): - message = 'Could not find pod [{}]'.format(data.pod_name) - return httplib.NOT_FOUND, message + return httplib.NOT_FOUND, message.not_found('pod', data.pod_name) def project_query(data): return {'name': data.project_name} def project_error(data): - message = 'Could not find project [{}]'.format(data.project_name) - return httplib.NOT_FOUND, message + return httplib.NOT_FOUND, message.not_found('project', + data.project_name) def testcase_query(data): return {'project_name': data.project_name, 'name': data.case_name} def testcase_error(data): - message = 'Could not find testcase [{}] in project [{}]'\ - .format(data.case_name, data.project_name) - return httplib.NOT_FOUND, message + return httplib.NOT_FOUND, message.not_found('testcase', + data.case_name) miss_checks = ['pod_name', 'project_name', 'case_name'] db_checks = [('pods', True, pod_query, pod_error), -- cgit 1.2.3-korg