diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-05-19 18:13:27 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-05-19 18:18:07 +0800 |
commit | f25ad4e8a7e4bd6505b2144494da81fbcad40b7d (patch) | |
tree | c811d7b15048680d7d6717beb02bfbfa75aea717 /utils/test/result_collection_api/resources/pod_models.py | |
parent | 598be795dec8fa11bee7b6e140b33947ab35b8f0 (diff) |
add unittests of project & refactor response
post body: {'href':'<http://ip:8000/pods/pod_name >'}
get body: Pod/Project
list body: list of Pod/Project
update body: Pod/Project
delete: no body
JIRA: FUNCTEST-253
Change-Id: I28c6f5b35d8909d827f2f803197d95be4abd44bb
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'utils/test/result_collection_api/resources/pod_models.py')
-rw-r--r-- | utils/test/result_collection_api/resources/pod_models.py | 59 |
1 files changed, 6 insertions, 53 deletions
diff --git a/utils/test/result_collection_api/resources/pod_models.py b/utils/test/result_collection_api/resources/pod_models.py index 5c4ef7221..65b82f770 100644 --- a/utils/test/result_collection_api/resources/pod_models.py +++ b/utils/test/result_collection_api/resources/pod_models.py @@ -1,4 +1,4 @@ -from models import MetaCreateResponse, MetaGetResponse +__author__ = '__serena__' class PodCreateRequest(object): @@ -14,17 +14,6 @@ class PodCreateRequest(object): "details": self.details, } - @staticmethod - def from_dict(req_dict): - if req_dict is None: - return None - - req = PodCreateRequest() - req.name = req_dict.get('name') - req.mode = req_dict.get('mode') - req.details = req_dict.get('details') - return req - class Pod(PodCreateRequest): """ describes a POD platform """ @@ -34,7 +23,7 @@ class Pod(PodCreateRequest): self.creation_date = create_date @staticmethod - def pod_from_dict(pod_dict): + def from_dict(pod_dict): if pod_dict is None: return None @@ -57,52 +46,16 @@ class Pod(PodCreateRequest): return f -class PodCreateResponse(object): - def __init__(self, pod=None, meta=None): - self.pod = pod - self.meta = meta - - @staticmethod - def from_dict(res_dict): - if res_dict is None: - return None - - res = PodCreateResponse() - res.pod = Pod.pod_from_dict(res_dict.get('pod')) - res.meta = MetaCreateResponse.from_dict(res_dict.get('meta')) - return res - - -class PodGetResponse(PodCreateRequest): - def __init__(self, name='', mode='', details='', create_date=''): - self.creation_date = create_date - super(PodGetResponse, self).__init__(name, mode, details) - - @staticmethod - def from_dict(req_dict): - if req_dict is None: - return None - - res = PodGetResponse() - res.creation_date = str(req_dict.get('creation_date')) - res.name = req_dict.get('name') - res.mode = req_dict.get('mode') - res.details = req_dict.get('details') - return res - - -class PodsGetResponse(object): - def __init__(self, pods=[], meta=None): +class Pods(object): + def __init__(self, pods=list()): self.pods = pods - self.meta = meta @staticmethod def from_dict(res_dict): if res_dict is None: return None - res = PodsGetResponse() + res = Pods() for pod in res_dict.get('pods'): - res.pods.append(PodGetResponse.from_dict(pod)) - res.meta = MetaGetResponse.from_dict(res_dict.get('meta')) + res.pods.append(Pod.from_dict(pod)) return res |