summaryrefslogtreecommitdiffstats
path: root/api/actions/test.py
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2016-11-30 07:28:36 +0000
committerchenjiankun <chenjiankun1@huawei.com>2016-11-30 07:28:36 +0000
commit1558bcf48bdba369187d7cb07482f2fbcc6f4feb (patch)
treea18ac011457cf219503bbeb79d83662bb2f67b4a /api/actions/test.py
parented89d5d7372b598a3b849f7753e8d29a39282d53 (diff)
Use flask jsonify method to return json result
JIRA: YARDSTICK-433 Python json lib is very hard to parse when transport via network. Flask jsonfiy is more easier to use. Change-Id: I2afd5238d65bc474170c57d2f9307dc881ea4990 Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'api/actions/test.py')
-rw-r--r--api/actions/test.py14
1 files changed, 2 insertions, 12 deletions
diff --git a/api/actions/test.py b/api/actions/test.py
index b1dc212c2..fda0ffd32 100644
--- a/api/actions/test.py
+++ b/api/actions/test.py
@@ -7,7 +7,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import uuid
-import json
import os
import logging
@@ -22,12 +21,7 @@ def runTestCase(args):
opts = args.get('opts', {})
testcase = args['testcase']
except KeyError:
- logger.error('Lack of testcase argument')
- result = {
- 'status': 'error',
- 'message': 'need testcase name'
- }
- return json.dumps(result)
+ return common_utils.error_handler('Lack of testcase argument')
testcase = os.path.join(conf.TEST_CASE_PATH,
conf.TEST_CASE_PRE + testcase + '.yaml')
@@ -41,8 +35,4 @@ def runTestCase(args):
logger.debug('Start to execute command list')
common_utils.exec_command_task(command_list, task_id)
- result = {
- 'status': 'success',
- 'task_id': task_id
- }
- return json.dumps(result)
+ return common_utils.result_handler('success', task_id)