diff options
author | chenjiankun <chenjiankun1@huawei.com> | 2017-07-31 02:49:12 +0000 |
---|---|---|
committer | Jack Chan <chenjiankun1@huawei.com> | 2017-08-02 01:00:12 +0000 |
commit | d5ff38b3ff3309cb1fed11266c98aca23001ea44 (patch) | |
tree | a54024697405526058c0758fe79e0bc8d1cb5920 /api | |
parent | 5abe4fe013a14c528bfb1e0ff4c8bcb9b8817551 (diff) |
Add task-args(from yaml file) candidates in /api/v2/yardstick/testcases API
JIRA: YARDSTICK-766
We have the demand to get all task-args candidates in test case yaml
file,
so that user get easily change it.
The response will like:
{
'status': 1,
'result': {
'testcase': case content,
'args': {
'image': {'description': '', 'type': 'String'}
}
}
}
In this patch, I add jinja2schema 0.1.4 in requirements.txt.
Change-Id: I450082402370add5ab29090286f026fe3cc8c36e
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'api')
-rw-r--r-- | api/resources/v2/testcases.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/api/resources/v2/testcases.py b/api/resources/v2/testcases.py index b47a8f6b7..316ef2664 100644 --- a/api/resources/v2/testcases.py +++ b/api/resources/v2/testcases.py @@ -10,6 +10,8 @@ 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 @@ -56,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)) |