예제 #1
0
 def test_build_cycle_references(self,
                                 testcase_cycle_references_tree_items):
     items = testcase_cycle_references_tree_items
     tree = Tree.build(items, 'name', 'parent')
     print('', tree, sep='\n')
     with raises(RecursionError):
         tree.render()
예제 #2
0
    def testcase_simple_tree(self, name_handle, children_handle, render_style,
                             root_item):
        """Tree with children references: (Tree() object, tree representation string, render style used)"""

        representation = {
            'strict':
            '''
                f
                └── e
                    ├── a
                    ├── b
                    │   └── c
                    └── d
                ''',
            'smooth':
            '''
                f
                ╰── e
                    ├── a
                    ├── b
                    │   ╰── c
                    ╰── d
                ''',
            'indent':
            '''
                f
                    e
                        a
                        b
                            c
                        d
                ''',
        }

        tree = Tree.convert(root_item, name_handle, children_handle)
        return tree, self.strip_indents(representation[render_style],
                                        4), render_style
예제 #3
0
def get_server_dir_info():
    tree = Tree()
    tree.walk(basedir)
    return tree.retString
예제 #4
0
 def test_build_multiple_roots(self, testcase_multiple_roots_tree_items):
     items = testcase_multiple_roots_tree_items
     with raises(
             RuntimeError,
             match='Given collection of items is not a connected graph!'):
         Tree.build(items, 'name', 'parent')
예제 #5
0
 def test_build_missing_non_leaves_items(self, testcase_missing_tree_items,
                                         items_order):
     items, rendered = testcase_missing_tree_items
     tree = Tree.build(items, 'name', 'parent')
     print('', tree, sep='\n')
     assert tree.render() == rendered
예제 #6
0
 def test_build_chain_layout(self, testcase_chain_layout_tree_items):
     items, rendered = testcase_chain_layout_tree_items
     tree = Tree.build(items, 'name', 'parent')
     print('', tree, sep='\n')
     assert tree.render() == rendered
예제 #7
0
 def test_build_single_item(self, testcase_single_item_tree_items):
     items, rendered = testcase_single_item_tree_items
     tree = Tree.build(items, 'name', 'parent')
     print('', tree, sep='\n')
     assert tree.render() == rendered
예제 #8
0
 def test_build_empty(self, testcase_empty_tree_items):
     items, rendered = testcase_empty_tree_items
     tree = Tree.build(items, 'name', 'parent')
     print('', tree.render(empty=rendered), sep='\n')
     assert tree.render(empty=rendered) == rendered
예제 #9
0
 def test_build_exceptions(self, testcase_exception_tree_items):
     items, rendered = testcase_exception_tree_items
     tree = Tree.build(items=items, naming='__name__', parent='__base__')
     print('', tree, sep='\n')
     assert tree.render() == rendered
예제 #10
0
 def test_invalid_children_handle(self, name_handle, children_handle,
                                  root_item):
     err_msg = r"children handle returned invalid result: expected List\[Item\], got 0"
     with raises(RuntimeError, match=err_msg):
         Tree.convert(root_item, name_handle, children_handle)
예제 #11
0
 def testcase_single_item_tree(self, name_handle, children_handle):
     """Tree of with 1 single node: (Tree() object, rendered tree string)"""
     item = self.Item('item', None)
     return Tree.convert(item, name_handle, children_handle), 'item'
예제 #12
0
 def testcase_empty_tree(self, empty_arg):
     """Tree with an empty root: (Tree() object, empty tree representation string, 'empty' argument)"""
     result = empty_arg
     return Tree(None), result, empty_arg