Exemple #1
0
def test_find_one_by_name(test_tree: Tree):
    assert test_tree.find_one_by_name("child2_child1").name == "child2_child1"
Exemple #2
0
def test_add_child(test_tree: Tree):
    test_tree.add_child(Tree(name="child4"))
    assert len(test_tree.children) == 4
    assert test_tree.find_one_by_name("child4") == Tree(name="child4")
Exemple #3
0
def test_depth(test_tree: Tree):
    assert test_tree.depth() == 4
    assert test_tree.find_one_by_name("child1").depth() == 2
    assert test_tree.find_one_by_name("child3").depth() == 3
    assert test_tree.find_one_by_name("child3_child3_child1").depth() == 1
Exemple #4
0
def test_is_leaf(test_tree: Tree):
    assert not test_tree.is_leaf()
    assert not test_tree.find_one_by_name("child1").is_leaf()
    assert test_tree.find_one_by_name("child1_child1").is_leaf()