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"
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"
def test_isleaf(): node = Node("0") sub_node = Node("1") node.append(sub_node) assert not node.isleaf assert sub_node.isleaf
def test_isroot(): node = Node("0") sub_node = Node("1") node.append(sub_node) assert node.isroot assert not sub_node.isroot
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
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"
def test_root(): node = Node("0") sub_node = Node("1") node.append(sub_node) assert sub_node.root is node
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"