diff options
author | Linda Wang <wangwulin@huawei.com> | 2017-08-18 06:09:56 +0000 |
---|---|---|
committer | Linda Wang <wangwulin@huawei.com> | 2017-08-21 02:47:42 +0000 |
commit | 26efacba9304071956d16a9a50a18e8f243518bb (patch) | |
tree | 38c8cdb8c363f1f9592be904b6e805567c3be66d /functest/api/resources/v1/envs.py | |
parent | 58665932c2c910cedac2a135e5b84a5ec4b5946e (diff) |
Create API to run a test case
Two APIs are created here:
1. Run a test case
2. Get the result of the task id
JIRA: FUNCTEST-853
Change-Id: I12950933b143b82fb6aeb186ea1b35ddd16e6097
Signed-off-by: Linda Wang <wangwulin@huawei.com>
Diffstat (limited to 'functest/api/resources/v1/envs.py')
-rw-r--r-- | functest/api/resources/v1/envs.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/functest/api/resources/v1/envs.py b/functest/api/resources/v1/envs.py index 35bffb04..9c455198 100644 --- a/functest/api/resources/v1/envs.py +++ b/functest/api/resources/v1/envs.py @@ -14,6 +14,7 @@ from flask import jsonify from functest.api.base import ApiResource from functest.cli.commands.cli_env import Env +from functest.api.common import api_utils import functest.utils.functest_utils as ft_utils @@ -31,4 +32,9 @@ class V1Envs(ApiResource): def prepare(self, args): # pylint: disable=no-self-use, unused-argument """ Prepare environment """ - ft_utils.execute_command("prepare_env start") + try: + ft_utils.execute_command("prepare_env start") + except Exception as err: # pylint: disable=broad-except + return api_utils.result_handler(status=1, data=str(err)) + return api_utils.result_handler( + status=0, data="Prepare env successfully") |