Exemplo n.º 1
0
def test_append(simple_node):
    node = Node("1")
    node.append("a")
    assert node.children[0].name == "a"

    simple_node.append(node)
    assert simple_node["1"].children.named_lists[0][-1].name == "a"
Exemplo n.º 2
0
def test_full_name():
    node = Node("0")
    sub_node = Node("1")
    node.append(sub_node)

    assert node.full_name == "0"
    assert sub_node.full_name == "0/1"
Exemplo n.º 3
0
def test_isleaf():
    node = Node("0")
    sub_node = Node("1")
    node.append(sub_node)

    assert not node.isleaf
    assert sub_node.isleaf
Exemplo n.º 4
0
def test_isroot():
    node = Node("0")
    sub_node = Node("1")
    node.append(sub_node)

    assert node.isroot
    assert not sub_node.isroot
Exemplo n.º 5
0
def test_attr():
    node = Node("0")
    sub_node = Node("1")
    node.append(sub_node)

    assert node.children[0] is sub_node
    assert sub_node.parent is node
Exemplo n.º 6
0
def test_or(simple_node):
    node = Node("0")
    node.append("a")

    result_node = simple_node | node
    assert result_node is simple_node
    assert result_node.children["a"].name == "a"
Exemplo n.º 7
0
def test_root():
    node = Node("0")
    sub_node = Node("1")
    node.append(sub_node)

    assert sub_node.root is node
Exemplo n.º 8
0
def test_merge(simple_node):
    node = Node("0")
    node.append("a")

    simple_node.merge(node)
    assert simple_node.children.named_lists[0][-1].name == "a"