diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2017-01-17 14:55:02 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2017-01-18 17:52:54 +0800 |
commit | 8ce27ce11a5916d9b725ff74be304805c0c3ebe7 (patch) | |
tree | 26e08633e30baae180fca2b5e658c952acc35551 /utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py | |
parent | a83e598c5401531d8f4010f16a7c41461fa4e828 (diff) |
implement get/query scenario(s) and add unittest
supported queries: scenario name/version/installer/project
JIRA: RELENG-163
Change-Id: I3f6ea6e3c81edff30569918e0789e8c1e693b9fc
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py')
-rw-r--r-- | utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py index 7bf3d5d53..28fe28e68 100644 --- a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py @@ -19,11 +19,49 @@ class ScenariosCLHandler(GenericScenarioHandler): """ @description: Retrieve scenario(s). @notes: Retrieve scenario(s) - @return 200: all scenarios consist with query, + Available filters for this request are : + - name : scenario name + + GET /scenarios?name=scenario_1 + @param name: scenario name + @type name: L{string} + @in name: query + @required name: False + @param installer: installer type + @type installer: L{string} + @in installer: query + @required installer: False + @param version: version + @type version: L{string} + @in version: query + @required version: False + @param project: project name + @type project: L{string} + @in project: query + @required project: False + @return 200: all scenarios satisfy queries, empty list if no scenario is found @rtype: L{Scenarios} """ - self._list() + + def _set_query(): + query = dict() + elem_query = dict() + for k in self.request.query_arguments.keys(): + v = self.get_query_argument(k) + if k == 'installer': + elem_query["installer"] = v + elif k == 'version': + elem_query["versions.version"] = v + elif k == 'project': + elem_query["versions.projects.project"] = v + else: + query[k] = v + if elem_query: + query['installers'] = {'$elemMatch': elem_query} + return query + + self._list(_set_query()) @swagger.operation(nickname="Create a new scenario") def post(self): @@ -58,6 +96,7 @@ class ScenarioGURHandler(GenericScenarioHandler): @return 200: scenario exist @raise 404: scenario not exist """ + self._get_one({'name': name}) pass @swagger.operation(nickname="Update the scenario by name") @@ -65,7 +104,7 @@ class ScenarioGURHandler(GenericScenarioHandler): """ @description: update a single scenario by name @param body: fields to be updated - @type body: L{string} + @type body: L{ScenarioCreateRequest} @in body: body @rtype: L{Scenario} @return 200: update success |