tests/test_treeview.py
changeset 11 762513aacc87
child 19 5e78d52ebb24
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_treeview.py	Wed Aug 17 23:43:52 2011 +0200
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3
+
+from tuikit.treeview import *
+import unittest
+
+class TestTreeView(unittest.TestCase):
+    def test_treemodel(self):
+        '''Build tree model, iterate through the tree, test result.'''
+        # build tree model
+        # root
+        # ├ a
+        # │ ├ c
+        # │ └ d
+        # │   ├ e
+        # │   │ └ g
+        # │   └ f
+        # │     └ h
+        # └ b
+        model = TreeModel()
+        model.add('/',  ['a', 'b'])
+        model.add('/a', ['c', 'd'])
+        model.add((0,1), ['e', 'f'])
+        model.add('/0/1/0', 'g')
+        model.add('/a/d/f', 'h')
+        
+        res = ''
+        for l, i, c, n in model:
+            res += str(l) + str(i) + str(c) + n.name
+            
+        self.assertEqual(res, '112a212c222d312e411g322f411h122b')
+
+
+if __name__ == '__main__':
+    unittest.main()