From 3064b88ccd222c18352ac8be042d98904ca3828c Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Mon, 26 Dec 2016 17:34:05 +0800 Subject: add scenario models and framework JIRA: RELENG-163 Change-Id: I36a51022c087621d9539dc40f7d9acee4db95dfb Signed-off-by: SerenaFeng --- .../opnfv_testapi/resources/scenario_handlers.py | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py (limited to 'utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py') diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py new file mode 100644 index 000000000..75754d8b9 --- /dev/null +++ b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py @@ -0,0 +1,61 @@ +from opnfv_testapi.resources.handlers import GenericApiHandler +from opnfv_testapi.resources.scenario_models import Scenario +from opnfv_testapi.tornado_swagger import swagger + + +class GenericScenarioHandler(GenericApiHandler): + def __init__(self, application, request, **kwargs): + super(GenericScenarioHandler, self).__init__(application, + request, + **kwargs) + self.table = self.db_scenarios + self.table_cls = Scenario + + +class ScenariosCLHandler(GenericScenarioHandler): + @swagger.operation(nickname="List scenarios by queries") + def get(self): + """ + @description: Retrieve scenario(s). + @notes: Retrieve scenario(s) + @return 200: all scenarios consist with query, + empty list if no scenario is found + @rtype: L{Scenarios} + """ + self._list() + + @swagger.operation(nickname="Create a new scenario") + def post(self): + """ + @description: create a new scenario by name + @param body: scenario to be created + @type body: L{string} + @rtype: L{CreateResponse} + """ + pass + + +class ScenarioGURHandler(GenericScenarioHandler): + @swagger.operation(nickname='Get the scenario by name') + def get(self, name): + """ + @description: get a single scenario by name + @rtype: L{Scenario} + @return 200: scenario exist + @raise 404: scenario not exist + """ + pass + + @swagger.operation(nickname="Update the scenario by name") + def put(self, name): + """ + @description: update a single scenario by name + @param body: fields to be updated + @type body: L{string} + @in body: body + @rtype: L{Scenario} + @return 200: update success + @raise 404: scenario not exist + @raise 403: nothing to update + """ + pass -- cgit 1.2.3-korg