# are made available under the terms of the Apache License, Version 2.0\r
# which accompanies this distribution, and is available at\r
# http://www.apache.org/licenses/LICENSE-2.0\r
+# feng.xiaowei@zte.com.cn mv Pod to pod_models.py 6-18-2016\r
+# feng.xiaowei@zte.com.cn add MetaCreateResponse/MetaGetResponse 6-18-2016\r
##############################################################################\r
\r
\r
-class Pod:\r
- """ describes a POD platform """\r
- def __init__(self):\r
- self._id = ""\r
- self.name = ""\r
- self.creation_date = ""\r
- self.mode = ""\r
- self.details = ""\r
+class MetaCreateResponse(object):\r
+ def __init__(self, success=True, uri=''):\r
+ self.success = success\r
+ self.uri = uri\r
\r
@staticmethod\r
- def pod_from_dict(pod_dict):\r
- if pod_dict is None:\r
+ def from_dict(meta_dict):\r
+ if meta_dict is None:\r
return None\r
\r
- p = Pod()\r
- p._id = pod_dict.get('_id')\r
- p.creation_date = str(pod_dict.get('creation_date'))\r
- p.name = pod_dict.get('name')\r
- p.mode = pod_dict.get('mode')\r
- p.details = pod_dict.get('details')\r
- return p\r
+ meta = MetaCreateResponse()\r
+ meta.success = meta_dict.get('success')\r
+ meta.uri = meta_dict.get('uri')\r
+ return meta\r
\r
- def format(self):\r
- return {\r
- "name": self.name,\r
- "mode": self.mode,\r
- "details": self.details,\r
- "creation_date": str(self.creation_date),\r
- }\r
\r
- def format_http(self):\r
- return {\r
- "_id": str(self._id),\r
- "name": self.name,\r
- "mode": self.mode,\r
- "details": self.details,\r
- "creation_date": str(self.creation_date),\r
- }\r
+class MetaGetResponse(object):\r
+ def __init__(self, success=True, total=0):\r
+ self.success = success\r
+ self.total = total\r
+\r
+ @staticmethod\r
+ def from_dict(meta_dict):\r
+ if meta_dict is None:\r
+ return None\r
+\r
+ meta = MetaGetResponse()\r
+ meta.success = meta_dict.get('success')\r
+ meta.total = meta_dict.get('total')\r
+ return meta\r
\r
\r
class TestProject:\r
self.creation_date = None\r
self.details = None\r
self.build_tag = None\r
+ self.scenario = None\r
+ self.criteria = None\r
+ self.trust_indicator = None\r
\r
@staticmethod\r
def test_result_from_dict(test_result_dict):\r
t.version = test_result_dict.get('version')\r
t.installer = test_result_dict.get('installer')\r
t.build_tag = test_result_dict.get('build_tag')\r
-\r
+ t.scenario = test_result_dict.get('scenario')\r
+ t.criteria = test_result_dict.get('criteria')\r
+ # 0 < trust indicator < 1\r
+ # if bad value => set this indicator to 0\r
+ if test_result_dict.get('trust_indicator') is not None:\r
+ if isinstance(test_result_dict.get('trust_indicator'),\r
+ (int, long, float)):\r
+ if test_result_dict.get('trust_indicator') < 0:\r
+ t.trust_indicator = 0\r
+ elif test_result_dict.get('trust_indicator') > 1:\r
+ t.trust_indicator = 1\r
+ else:\r
+ t.trust_indicator = test_result_dict.get('trust_indicator')\r
+ else:\r
+ t.trust_indicator = 0\r
+ else:\r
+ t.trust_indicator = 0\r
return t\r
\r
def format(self):\r
"version": self.version,\r
"installer": self.installer,\r
"details": self.details,\r
- "build_tag": self.build_tag\r
+ "build_tag": self.build_tag,\r
+ "scenario": self.scenario,\r
+ "criteria": self.criteria,\r
+ "trust_indicator": self.trust_indicator\r
}\r
\r
def format_http(self):\r
"version": self.version,\r
"installer": self.installer,\r
"details": self.details,\r
- "build_tag": self.build_tag\r
+ "build_tag": self.build_tag,\r
+ "scenario": self.scenario,\r
+ "criteria": self.criteria,\r
+ "trust_indicator": self.trust_indicator\r
}\r
-\r