summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/opnfv_testapi/resources/testcase_models.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/resources/testcase_models.py')
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/testcase_models.py128
1 files changed, 17 insertions, 111 deletions
diff --git a/utils/test/testapi/opnfv_testapi/resources/testcase_models.py b/utils/test/testapi/opnfv_testapi/resources/testcase_models.py
index 0ed705f0f..8cc3c6c6a 100644
--- a/utils/test/testapi/opnfv_testapi/resources/testcase_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/testcase_models.py
@@ -6,11 +6,12 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import models
from opnfv_testapi.tornado_swagger import swagger
@swagger.model()
-class TestcaseCreateRequest(object):
+class TestcaseCreateRequest(models.ModelBase):
def __init__(self, name, url=None, description=None,
tier=None, ci_loop=None, criteria=None,
blocking=None, dependencies=None, run=None,
@@ -29,16 +30,9 @@ class TestcaseCreateRequest(object):
self.version = version
self.trust = "Silver"
- def format(self):
- return {
- "name": self.name,
- "description": self.description,
- "url": self.url,
- }
-
@swagger.model()
-class TestcaseUpdateRequest(object):
+class TestcaseUpdateRequest(models.ModelBase):
def __init__(self, name=None, description=None, project_name=None,
tier=None, ci_loop=None, criteria=None,
blocking=None, dependencies=None, run=None,
@@ -57,26 +51,9 @@ class TestcaseUpdateRequest(object):
self.version = version
self.trust = trust
- def format(self):
- return {
- "name": self.name,
- "description": self.description,
- "project_name": self.project_name,
- "tier": self.tier,
- "ci_loop": self.ci_loop,
- "criteria": self.criteria,
- "blocking": self.blocking,
- "dependencies": self.dependencies,
- "run": self.run,
- "domains": self.domains,
- "tags": self.tags,
- "version": self.version,
- "trust": self.trust
- }
-
@swagger.model()
-class Testcase(object):
+class Testcase(models.ModelBase):
def __init__(self, _id=None, name=None, project_name=None,
description=None, url=None, creation_date=None,
tier=None, ci_loop=None, criteria=None,
@@ -89,85 +66,20 @@ class Testcase(object):
self.description = None
self.url = None
self.creation_date = None
- self.tier=None
- self.ci_loop=None
- self.criteria=None
- self.blocking=None
- self.dependencies=None
- self.run=None
- self.domains=None
- self.tags=None
- self.version=None
- self.trust=None
-
- @staticmethod
- def from_dict(a_dict):
-
- if a_dict is None:
- return None
-
- t = Testcase()
- t._id = a_dict.get('_id')
- t.project_name = a_dict.get('project_name')
- t.creation_date = a_dict.get('creation_date')
- t.name = a_dict.get('name')
- t.description = a_dict.get('description')
- t.url = a_dict.get('url')
- t.tier = a_dict.get('tier')
- t.ci_loop = a_dict.get('ci_loop')
- t.criteria = a_dict.get('criteria')
- t.blocking = a_dict.get('blocking')
- t.dependencies = a_dict.get('dependencies')
- t.run = a_dict.get('run')
- t.domains = a_dict.get('domains')
- t.tags = a_dict.get('tags')
- t.version = a_dict.get('version')
- t.trust = a_dict.get('trust')
-
- return t
-
- def format(self):
- return {
- "name": self.name,
- "description": self.description,
- "project_name": self.project_name,
- "creation_date": str(self.creation_date),
- "url": self.url,
- "tier": self.tier,
- "ci_loop": self.ci_loop,
- "criteria": self.criteria,
- "blocking": self.blocking,
- "dependencies": self.dependencies,
- "run": self.run,
- "domains": self.domains,
- "tags": self.tags,
- "version": self.version,
- "trust": self.trust
- }
-
- def format_http(self):
- return {
- "_id": str(self._id),
- "name": self.name,
- "project_name": self.project_name,
- "description": self.description,
- "creation_date": str(self.creation_date),
- "url": self.url,
- "tier": self.tier,
- "ci_loop": self.ci_loop,
- "criteria": self.criteria,
- "blocking": self.blocking,
- "dependencies": self.dependencies,
- "run": self.run,
- "domains": self.domains,
- "tags": self.tags,
- "version": self.version,
- "trust": self.trust
- }
+ self.tier = None
+ self.ci_loop = None
+ self.criteria = None
+ self.blocking = None
+ self.dependencies = None
+ self.run = None
+ self.domains = None
+ self.tags = None
+ self.version = None
+ self.trust = None
@swagger.model()
-class Testcases(object):
+class Testcases(models.ModelBase):
"""
@property testcases:
@ptype testcases: C{list} of L{Testcase}
@@ -176,11 +88,5 @@ class Testcases(object):
self.testcases = list()
@staticmethod
- def from_dict(res_dict):
- if res_dict is None:
- return None
-
- res = Testcases()
- for testcase in res_dict.get('testcases'):
- res.testcases.append(Testcase.from_dict(testcase))
- return res
+ def attr_parser():
+ return {'testcases': Testcase}