X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=api%2Fresources%2Fv2%2Ftestcases.py;h=316ef2664513fad569324103e6b5fcc33e6b97e4;hb=ffecd5b84eecdb74d7534b801c1359251c34b34e;hp=81b4aa88c933c18d4f4d9ace6b02fca55fbbbd0c;hpb=50be49a89258a373aa1bb61b9f7fd2f26f9241e8;p=yardstick.git diff --git a/api/resources/v2/testcases.py b/api/resources/v2/testcases.py index 81b4aa88c..316ef2664 100644 --- a/api/resources/v2/testcases.py +++ b/api/resources/v2/testcases.py @@ -1,7 +1,17 @@ +############################################################################## +# Copyright (c) 2017 Huawei Technologies Co.,Ltd. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## import logging import errno import os +import jinja2schema + from api import ApiResource from yardstick.common.utils import result_handler from yardstick.common import constants as consts @@ -17,7 +27,7 @@ class V2Testcases(ApiResource): def get(self): param = Param({}) testcase_list = Testcase().list_all(param) - return result_handler(consts.API_SUCCESS, testcase_list) + return result_handler(consts.API_SUCCESS, {'testcases': testcase_list}) def post(self): return self._dispatch_post() @@ -48,7 +58,10 @@ class V2Testcase(ApiResource): if e.errno == errno.ENOENT: return result_handler(consts.API_ERROR, 'case does not exist') - return result_handler(consts.API_SUCCESS, {'testcase': data}) + options = {k: {'description': '', 'type': v.__class__.__name__} + for k, v in jinja2schema.infer(data).items()} + + return result_handler(consts.API_SUCCESS, {'testcase': data, 'args': options}) def delete(self, case_name): case_path = os.path.join(consts.TESTCASE_DIR, '{}.yaml'.format(case_name))