Пример #1
0
def test_create_children_based_on_lines_2():
    node_1 = Node(raw_text='Node 1')
    raw_lines = ['\tNode 1.1',
                 '\t\tNode 1.1.1',
                 '\t\tNode 1.1.2',
                 '\tNode 1.2',
                 '\tNode 1.3']
    node_1.add_children_based_on_lines(raw_lines)
    expected_lines = ['Node 1',
                      '    Node 1.1',
                      '        Node 1.1.1',
                      '        Node 1.1.2',
                      '    Node 1.2',
                      '    Node 1.3']
    actual_lines = []
    node_1.add_self_to_lines(actual_lines)
    assert_lines_equal(actual_lines, expected_lines)
Пример #2
0
def test_add_self_to_lines():
    node_1 = Node(raw_text='Node 1')
    node_1_1 = Node(raw_text='Node 1.1')
    node_1_1_1 = Node(raw_text='Node 1.1.1')
    node_1_1_2 = Node(raw_text='Node 1.1.2')
    node_1_2 = Node(raw_text='Node 1.2')

    node_1.add_child(node_1_1)
    node_1_1.add_child(node_1_1_1)
    node_1_1.add_child(node_1_1_2)
    node_1.add_child(node_1_2)

    expected_lines = ['Node 1',
                      '    Node 1.1',
                      '        Node 1.1.1',
                      '        Node 1.1.2',
                      '    Node 1.2']
    actual_lines = []
    node_1.add_self_to_lines(actual_lines)
    assert_lines_equal(actual_lines, expected_lines)