summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/opnfv_testapi/resources/project_models.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-12-20 12:02:03 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2016-12-20 14:58:13 +0800
commit64a8ba2e9fc51e9a6b1ef297dfe6c9e7bdbd5d36 (patch)
tree4c216f6fbd687f2d8787d9d59f19829bdac70742 /utils/test/testapi/opnfv_testapi/resources/project_models.py
parent2f439f57a70814427bdecbf56150bc7a2f31ac93 (diff)
simplify model process of TestAPI
JIRA: FUNCTEST-671 Change-Id: I8a398f04f2d12c880ec0803aa56c2645dc673523 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/resources/project_models.py')
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/project_models.py60
1 files changed, 7 insertions, 53 deletions
diff --git a/utils/test/testapi/opnfv_testapi/resources/project_models.py b/utils/test/testapi/opnfv_testapi/resources/project_models.py
index f70630cda..f7323c1c4 100644
--- a/utils/test/testapi/opnfv_testapi/resources/project_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/project_models.py
@@ -6,37 +6,26 @@
# 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 ProjectCreateRequest(object):
+class ProjectCreateRequest(models.ModelBase):
def __init__(self, name, description=''):
self.name = name
self.description = description
- def format(self):
- return {
- "name": self.name,
- "description": self.description,
- }
-
@swagger.model()
-class ProjectUpdateRequest(object):
+class ProjectUpdateRequest(models.ModelBase):
def __init__(self, name='', description=''):
self.name = name
self.description = description
- def format(self):
- return {
- "name": self.name,
- "description": self.description,
- }
-
@swagger.model()
-class Project(object):
+class Project(models.ModelBase):
def __init__(self,
name=None, _id=None, description=None, create_date=None):
self._id = _id
@@ -44,38 +33,9 @@ class Project(object):
self.description = description
self.creation_date = create_date
- @staticmethod
- def from_dict(res_dict):
-
- if res_dict is None:
- return None
-
- t = Project()
- t._id = res_dict.get('_id')
- t.creation_date = res_dict.get('creation_date')
- t.name = res_dict.get('name')
- t.description = res_dict.get('description')
-
- return t
-
- def format(self):
- return {
- "name": self.name,
- "description": self.description,
- "creation_date": str(self.creation_date)
- }
-
- def format_http(self):
- return {
- "_id": str(self._id),
- "name": self.name,
- "description": self.description,
- "creation_date": str(self.creation_date),
- }
-
@swagger.model()
-class Projects(object):
+class Projects(models.ModelBase):
"""
@property projects:
@ptype projects: C{list} of L{Project}
@@ -84,11 +44,5 @@ class Projects(object):
self.projects = list()
@staticmethod
- def from_dict(res_dict):
- if res_dict is None:
- return None
-
- res = Projects()
- for project in res_dict.get('projects'):
- res.projects.append(Project.from_dict(project))
- return res
+ def attr_parser():
+ return {'projects': Project}