diff options
author | Jose Lausuch <jose.lausuch@ericsson.com> | 2016-12-20 10:59:59 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2016-12-20 10:59:59 +0000 |
commit | 058a1240d5ba588fc375e70947b96deb7acfc9db (patch) | |
tree | e15e9aa59e9f2dcfb74556759ec3bb5b397b13ac /utils/test/testapi/opnfv_testapi/resources/pod_models.py | |
parent | af30c08dbbb593b7430473a3d836b2768f7fd899 (diff) | |
parent | 64a8ba2e9fc51e9a6b1ef297dfe6c9e7bdbd5d36 (diff) |
Merge "simplify model process of TestAPI"
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/resources/pod_models.py')
-rw-r--r-- | utils/test/testapi/opnfv_testapi/resources/pod_models.py | 55 |
1 files changed, 11 insertions, 44 deletions
diff --git a/utils/test/testapi/opnfv_testapi/resources/pod_models.py b/utils/test/testapi/opnfv_testapi/resources/pod_models.py index 7231806f6..26a9e6788 100644 --- a/utils/test/testapi/opnfv_testapi/resources/pod_models.py +++ b/utils/test/testapi/opnfv_testapi/resources/pod_models.py @@ -6,8 +6,10 @@ # 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 + # name: name of the POD e.g. zte-1 # mode: metal or virtual # details: any detail @@ -15,58 +17,29 @@ from opnfv_testapi.tornado_swagger import swagger @swagger.model() -class PodCreateRequest(object): +class PodCreateRequest(models.ModelBase): def __init__(self, name, mode='', details='', role=""): self.name = name self.mode = mode self.details = details self.role = role - def format(self): - return { - "name": self.name, - "mode": self.mode, - "details": self.details, - "role": self.role, - } - @swagger.model() -class Pod(PodCreateRequest): +class Pod(models.ModelBase): def __init__(self, name='', mode='', details='', role="", _id='', create_date=''): - super(Pod, self).__init__(name, mode, details, role) + self.name = name + self.mode = mode + self.details = details + self.role = role self._id = _id self.creation_date = create_date - @staticmethod - def from_dict(pod_dict): - if pod_dict is None: - return None - - p = Pod() - p._id = pod_dict.get('_id') - p.creation_date = str(pod_dict.get('creation_date')) - p.name = pod_dict.get('name') - p.mode = pod_dict.get('mode') - p.details = pod_dict.get('details') - p.role = pod_dict.get('role') - return p - - def format(self): - f = super(Pod, self).format() - f['creation_date'] = str(self.creation_date) - return f - - def format_http(self): - f = self.format() - f['_id'] = str(self._id) - return f - @swagger.model() -class Pods(object): +class Pods(models.ModelBase): """ @property pods: @ptype pods: C{list} of L{Pod} @@ -75,11 +48,5 @@ class Pods(object): self.pods = list() @staticmethod - def from_dict(res_dict): - if res_dict is None: - return None - - res = Pods() - for pod in res_dict.get('pods'): - res.pods.append(Pod.from_dict(pod)) - return res + def attr_parser(): + return {'pods': Pod} |