Exemple #1
0
def test_delete_leaf(animal):
    cat = animal.get('cat')
    lion = animal.get('lion')

    animal.delete('lion')

    assert lion not in cat._children
    assert lion._parent is None
Exemple #2
0
def test_delete_from_the_middle(animal):
    cat = animal.get('cat')
    lion = animal.get('lion')

    animal.delete('cat/lion')

    assert lion not in cat._children
    assert lion._parent is None
Exemple #3
0
def test_delete_3_nodes_path(animal):
    cat = animal.get('cat')
    lion = animal.get('lion')

    animal.delete('mammal/cat/lion')

    assert lion not in cat._children
    assert lion._parent is None
Exemple #4
0
def test_delete_2_nodes_path(animal):
    mammal = animal.get('mammal')
    cat = animal.get('cat')

    animal.delete('mammal/cat')

    assert cat not in mammal._children
    assert cat._parent is None
Exemple #5
0
def test_delete_1_node_path(animal):
    animal.delete('mammal')
    assert animal._children == []
Exemple #6
0
def test_delete_root(animal):
    with pytest.raises(RootDeleteError):
        animal.delete('animal')