summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-01-17 14:55:02 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2017-01-18 17:52:54 +0800
commit8ce27ce11a5916d9b725ff74be304805c0c3ebe7 (patch)
tree26e08633e30baae180fca2b5e658c952acc35551 /utils/test/testapi/opnfv_testapi/resources/scenario_models.py
parenta83e598c5401531d8f4010f16a7c41461fa4e828 (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_models.py')
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_models.py34
1 files changed, 27 insertions, 7 deletions
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
index b4bb3634b..f89a12428 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
@@ -11,7 +11,7 @@ class ScenarioTI(models.ModelBase):
@swagger.model()
class ScenarioScore(models.ModelBase):
- def __init__(self, date=None, score=''):
+ def __init__(self, date=None, score='0'):
self.date = date
self.score = score
@@ -27,14 +27,19 @@ class ScenarioProject(models.ModelBase):
@ptype trust_indicators: C{list} of L{ScenarioTI}
"""
def __init__(self,
- name='',
+ project='',
customs=None,
scores=None,
trust_indicators=None):
- self.name = name
+ self.project = project
self.customs = customs
self.scores = scores
- self.trust_indicator = trust_indicators
+ self.trust_indicators = trust_indicators
+
+ @staticmethod
+ def attr_parser():
+ return {'scores': ScenarioScore,
+ 'trust_indicators': ScenarioTI}
@swagger.model()
@@ -43,10 +48,14 @@ class ScenarioVersion(models.ModelBase):
@property projects:
@ptype projects: C{list} of L{ScenarioProject}
"""
- def __init__(self, version, projects=None):
+ def __init__(self, version=None, projects=None):
self.version = version
self.projects = projects
+ @staticmethod
+ def attr_parser():
+ return {'projects': ScenarioProject}
+
@swagger.model()
class ScenarioInstaller(models.ModelBase):
@@ -54,11 +63,14 @@ class ScenarioInstaller(models.ModelBase):
@property versions:
@ptype versions: C{list} of L{ScenarioVersion}
"""
- def __init__(self, installer=None, owner=None, versions=None):
+ def __init__(self, installer=None, versions=None):
self.installer = installer
- self.owner = owner
self.versions = versions if versions else list()
+ @staticmethod
+ def attr_parser():
+ return {'versions': ScenarioVersion}
+
@swagger.model()
class ScenarioCreateRequest(models.ModelBase):
@@ -70,6 +82,10 @@ class ScenarioCreateRequest(models.ModelBase):
self.name = name
self.installers = installers if installers else list()
+ @staticmethod
+ def attr_parser():
+ return {'installers': ScenarioInstaller}
+
@swagger.model()
class Scenario(models.ModelBase):
@@ -83,6 +99,10 @@ class Scenario(models.ModelBase):
self.creation_date = create_date
self.installers = installers if installers else list()
+ @staticmethod
+ def attr_parser():
+ return {'installers': ScenarioInstaller}
+
@swagger.model()
class Scenarios(models.ModelBase):