Exemplo n.º 1
0
def test_fbt_three_nodes():
    tree = BinaryTree()
    tree.add(45)
    tree.add(10)
    tree.add(7)
    fb_tree = fizz_buzz_tree(tree)
    actual = str(fb_tree)
    expected = "FizzBuzz--> Buzz--> 7--> NULL"
    assert actual == expected
Exemplo n.º 2
0
def test_fizz_buzz_tree():
    tree = BinaryTree()
    tree.add(1)
    tree.add(5)
    tree.add(4)
    tree.add(7)
    new_tree = fizz_buzz_tree(tree)
    actual = new_tree.breadth_first()
    expected = ['1', 'Buzz', '4', '7']
    assert actual == expected
Exemplo n.º 3
0
def test_fizz_buzz_tree_2():
    tree = BinaryTree()
    tree.add(3)
    tree.add(15)
    tree.add(7)
    tree.add(5)
    tree.add(3)
    tree.add(5)
    tree.add(15)
    new_tree = fizz_buzz_tree(tree)
    actual = new_tree.breadth_first()
    expected = ['Fizz', 'FizzBuzz', '7', 'Buzz', 'Fizz', 'Buzz', 'FizzBuzz']
    assert actual == expected
Exemplo n.º 4
0
def test_fbt_raise_error_not_tree():
    node = Node("bt")
    with pytest.raises(ValueError):
        fizz_buzz_tree(node)
Exemplo n.º 5
0
def test_fbt_multiple_nodes(bt_full):
    fb_tree = fizz_buzz_tree(bt_full)
    actual = str(fb_tree)
    expected = "FizzBuzz--> FizzBuzz--> Buzz--> Fizz--> 22--> NULL"
    assert actual == expected
Exemplo n.º 6
0
def test_fbt_not_same_as_tree():
    bt = BinaryTree()
    bt.add(21)
    fb_tree = fizz_buzz_tree(bt)
    assert fb_tree is not bt
    assert fb_tree.root is not bt.root
Exemplo n.º 7
0
def test_fbt_raise_error_no_root():
    tree = BinaryTree()
    with pytest.raises(Exception):
        fizz_buzz_tree(tree)