diff options
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/resources/project_models.py')
-rw-r--r-- | utils/test/testapi/opnfv_testapi/resources/project_models.py | 60 |
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} |