add pod related unittests in testAPI
[releng.git] / utils / test / result_collection_api / resources / models.py
index 06e95f9..adf6842 100644 (file)
@@ -5,47 +5,41 @@
 # 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