diff options
author | Serena Feng <feng.xiaowei@zte.com.cn> | 2017-01-20 09:56:05 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-01-20 09:56:05 +0000 |
commit | 5eb50c1f161a7bc1814b5f5082db93eedf7839ba (patch) | |
tree | 499cb77e127be26eddae93c30bef7388fe50404c /utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py | |
parent | 79c0c69780542b6064fcb98940c89086205e92da (diff) | |
parent | 8ce27ce11a5916d9b725ff74be304805c0c3ebe7 (diff) |
Merge "implement get/query scenario(s) and add unittest"
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 |