[Kimchi-devel] [PATCH v2 2/2] Add test cases for RootModel

Mark Wu wudxw at linux.vnet.ibm.com
Thu Jan 23 05:41:47 UTC 2014


It can be verified by test_plugin, but better to have direct unit
tests.

Signed-off-by: Mark Wu <wudxw at linux.vnet.ibm.com>
---
 tests/test_model.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/tests/test_model.py b/tests/test_model.py
index 8077f4d..1a9e198 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -751,3 +751,25 @@ class ModelTests(unittest.TestCase):
             time.sleep(1)
             volumes = inst.storagevolumes_get_list(args['name'])
             self.assertEquals(len(volumes), 2)
+
+
+class RootModelTests(unittest.TestCase):
+    class FoosModel(object):
+        def __init__(self):
+            self.data = {}
+
+        def create(self, params):
+            self.data.update(params)
+
+        def get_list(self):
+            return list(self.data)
+
+    class TestModel(kimchi.model.RootModel):
+        def __init__(self):
+            foo = RootModelTests.FoosModel()
+            super(RootModelTests.TestModel, self).__init__([foo])
+
+    def test_root_model(self):
+        t = RootModelTests.TestModel()
+        t.foos_create({'item1': 10})
+        self.assertEquals(t.foos_get_list(), ['item1'])
-- 
1.8.4.2




More information about the Kimchi-devel mailing list