summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/opnfv_testapi/resources
diff options
context:
space:
mode:
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/resources')
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py18
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_models.py13
2 files changed, 28 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 75754d8b9..7bf3d5d53 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
@@ -1,3 +1,4 @@
+from opnfv_testapi.common.constants import HTTP_FORBIDDEN
from opnfv_testapi.resources.handlers import GenericApiHandler
from opnfv_testapi.resources.scenario_models import Scenario
from opnfv_testapi.tornado_swagger import swagger
@@ -29,10 +30,23 @@ class ScenariosCLHandler(GenericScenarioHandler):
"""
@description: create a new scenario by name
@param body: scenario to be created
- @type body: L{string}
+ @type body: L{ScenarioCreateRequest}
+ @in body: body
@rtype: L{CreateResponse}
+ @return 200: scenario is created.
+ @raise 403: scenario already exists
+ @raise 400: body or name not provided
"""
- pass
+ def query(data):
+ return {'name': data.name}
+
+ def error(data):
+ message = '{} already exists as a scenario'.format(data.name)
+ return HTTP_FORBIDDEN, message
+
+ miss_checks = ['name']
+ db_checks = [(self.table, False, query, error)]
+ self._create(miss_checks=miss_checks, db_checks=db_checks)
class ScenarioGURHandler(GenericScenarioHandler):
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
index 0748a3738..b4bb3634b 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
@@ -61,6 +61,17 @@ class ScenarioInstaller(models.ModelBase):
@swagger.model()
+class ScenarioCreateRequest(models.ModelBase):
+ """
+ @property installers:
+ @ptype installers: C{list} of L{ScenarioInstaller}
+ """
+ def __init__(self, name='', installers=None):
+ self.name = name
+ self.installers = installers if installers else list()
+
+
+@swagger.model()
class Scenario(models.ModelBase):
"""
@property installers:
@@ -69,7 +80,7 @@ class Scenario(models.ModelBase):
def __init__(self, name='', create_date='', _id='', installers=None):
self.name = name
self._id = _id
- self.create_date = create_date
+ self.creation_date = create_date
self.installers = installers if installers else list()