From 808319c010baf449808214ec06237b4703af39c6 Mon Sep 17 00:00:00 2001 From: Linda Wang Date: Tue, 5 Sep 2017 12:22:27 +0000 Subject: unify all the return status as number Change-Id: I835a368fe78329e60e811e40c24f3609c7a8960c Signed-off-by: Linda Wang --- functest/api/resources/v1/testcases.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'functest/api/resources/v1/testcases.py') diff --git a/functest/api/resources/v1/testcases.py b/functest/api/resources/v1/testcases.py index d708cf37..b7d7b4aa 100644 --- a/functest/api/resources/v1/testcases.py +++ b/functest/api/resources/v1/testcases.py @@ -17,7 +17,7 @@ import pkg_resources import uuid import ConfigParser -from flask import abort, jsonify +from flask import jsonify from functest.api.base import ApiResource from functest.api.common import api_utils, thread @@ -46,8 +46,11 @@ class V1Testcase(ApiResource): """ GET the info of one testcase""" testcase = Testcase().show(testcase_name) if not testcase: - abort(404, "The test case '%s' does not exist or is not supported" - % testcase_name) + return api_utils.result_handler( + status=1, + data="The test case '%s' does not exist or is not supported" + % testcase_name) + testcase_info = api_utils.change_obj_to_dict(testcase) dependency_dict = api_utils.change_obj_to_dict( testcase_info.get('dependency')) @@ -70,6 +73,13 @@ class V1Testcase(ApiResource): return api_utils.result_handler( status=1, data='testcase name must be provided') + testcase = Testcase().show(case_name) + if not testcase: + return api_utils.result_handler( + status=1, + data="The test case '%s' does not exist or is not supported" + % case_name) + task_id = str(uuid.uuid4()) task_args = {'testcase': case_name, 'task_id': task_id} -- cgit 1.2.3-korg