summaryrefslogtreecommitdiffstats
path: root/utils/test/result_collection_api/resources/models.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-05-19 18:13:27 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2016-05-19 18:18:07 +0800
commitf25ad4e8a7e4bd6505b2144494da81fbcad40b7d (patch)
treec811d7b15048680d7d6717beb02bfbfa75aea717 /utils/test/result_collection_api/resources/models.py
parent598be795dec8fa11bee7b6e140b33947ab35b8f0 (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/models.py')
-rw-r--r--utils/test/result_collection_api/resources/models.py79
1 files changed, 14 insertions, 65 deletions
diff --git a/utils/test/result_collection_api/resources/models.py b/utils/test/result_collection_api/resources/models.py
index adf6842c3..56530e827 100644
--- a/utils/test/result_collection_api/resources/models.py
+++ b/utils/test/result_collection_api/resources/models.py
@@ -5,80 +5,29 @@
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
-# feng.xiaowei@zte.com.cn mv Pod to pod_models.py 6-18-2016
-# feng.xiaowei@zte.com.cn add MetaCreateResponse/MetaGetResponse 6-18-2016
+# feng.xiaowei@zte.com.cn mv Pod to pod_models.py 5-18-2016
+# feng.xiaowei@zte.com.cn add MetaCreateResponse/MetaGetResponse 5-18-2016
+# feng.xiaowei@zte.com.cn mv TestProject to project_models.py 5-19-2016
+# feng.xiaowei@zte.com.cn delete meta class 5-19-2016
+# feng.xiaowei@zte.com.cn add CreateResponse 5-19-2016
##############################################################################
-class MetaCreateResponse(object):
- def __init__(self, success=True, uri=''):
- self.success = success
- self.uri = uri
+class CreateResponse(object):
+ def __init__(self, href=''):
+ self.href = href
@staticmethod
- def from_dict(meta_dict):
- if meta_dict is None:
+ def from_dict(res_dict):
+ if res_dict is None:
return None
- meta = MetaCreateResponse()
- meta.success = meta_dict.get('success')
- meta.uri = meta_dict.get('uri')
- return meta
-
-
-class MetaGetResponse(object):
- def __init__(self, success=True, total=0):
- self.success = success
- self.total = total
-
- @staticmethod
- def from_dict(meta_dict):
- if meta_dict is None:
- return None
-
- meta = MetaGetResponse()
- meta.success = meta_dict.get('success')
- meta.total = meta_dict.get('total')
- return meta
-
-
-class TestProject:
- """ Describes a test project"""
-
- def __init__(self):
- self._id = None
- self.name = None
- self.description = None
- self.creation_date = None
-
- @staticmethod
- def testproject_from_dict(testproject_dict):
-
- if testproject_dict is None:
- return None
-
- t = TestProject()
- t._id = testproject_dict.get('_id')
- t.creation_date = testproject_dict.get('creation_date')
- t.name = testproject_dict.get('name')
- t.description = testproject_dict.get('description')
-
- return t
+ res = CreateResponse()
+ res.href = res_dict.get('href')
+ return res
def format(self):
- return {
- "name": self.name,
- "description": self.description,
- "creation_date": str(self.creation_date)
- }
-
- def format_http(self, test_cases=0):
- return {
- "_id": str(self._id),
- "name": self.name,
- "description": self.description,
- "creation_date": str(self.creation_date),
- }
+ return {'href': self.href}
class TestCase: