From 8ce27ce11a5916d9b725ff74be304805c0c3ebe7 Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Tue, 17 Jan 2017 14:55:02 +0800 Subject: 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 --- .../opnfv_testapi/resources/scenario_models.py | 34 +++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'utils/test/testapi/opnfv_testapi/resources/scenario_models.py') 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): -- cgit 1.2.3-korg