tests/test_treeview.py
changeset 11 762513aacc87
child 19 5e78d52ebb24
equal deleted inserted replaced
10:ec1d47e6fe09 11:762513aacc87
       
     1 #!/usr/bin/env python3
       
     2 
       
     3 from tuikit.treeview import *
       
     4 import unittest
       
     5 
       
     6 class TestTreeView(unittest.TestCase):
       
     7     def test_treemodel(self):
       
     8         '''Build tree model, iterate through the tree, test result.'''
       
     9         # build tree model
       
    10         # root
       
    11         # ├ a
       
    12         # │ ├ c
       
    13         # │ └ d
       
    14         # │   ├ e
       
    15         # │   │ └ g
       
    16         # │   └ f
       
    17         # │     └ h
       
    18         # └ b
       
    19         model = TreeModel()
       
    20         model.add('/',  ['a', 'b'])
       
    21         model.add('/a', ['c', 'd'])
       
    22         model.add((0,1), ['e', 'f'])
       
    23         model.add('/0/1/0', 'g')
       
    24         model.add('/a/d/f', 'h')
       
    25         
       
    26         res = ''
       
    27         for l, i, c, n in model:
       
    28             res += str(l) + str(i) + str(c) + n.name
       
    29             
       
    30         self.assertEqual(res, '112a212c222d312e411g322f411h122b')
       
    31 
       
    32 
       
    33 if __name__ == '__main__':
       
    34     unittest.main()