diff options
Diffstat (limited to 'functest/api/resources/v1/testcases.py')
-rw-r--r-- | functest/api/resources/v1/testcases.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/functest/api/resources/v1/testcases.py b/functest/api/resources/v1/testcases.py index d708cf37..cc2d4e19 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} @@ -79,8 +89,8 @@ class V1Testcase(ApiResource): task_thread = thread.TaskThread(self._run, task_args, TasksHandler()) task_thread.start() - results = {'testcase': case_name, 'task_id': task_id} - return jsonify(results) + result = {'testcase': case_name, 'task_id': task_id} + return jsonify({'result': result}) def _run(self, args): # pylint: disable=no-self-use """ The built_in function to run a test case """ @@ -110,7 +120,7 @@ class V1Testcase(ApiResource): } result = { 'task_id': args.get('task_id'), - 'case_name': case_name, + 'testcase': case_name, 'env_info': env_info, 'result': result } |