def test_same_length_tree():
    bt1 = BinaryTree()
    bt1.root = Node(2)
    bt1.root.left = Node(7)
    bt1.root.right = Node(5)
    bt1.root.left.left = Node(2)
    bt1.root.left.right = Node(6)
    bt1.root.right.right = Node(9)
    bt1.root.left.right.left = Node(5)
    bt1.root.left.right.right = Node(11)
    bt1.root.right.right.left = Node(4)

    bt2 = BinaryTree()
    bt2.root = Node(2)
    bt2.root.left = Node(7)
    bt2.root.right = Node(5)
    bt2.root.left.left = Node(5)
    bt2.root.left.right = Node(6)
    bt2.root.right.right = Node(9)
    bt2.root.left.right.left = Node(5)
    bt2.root.left.right.right = Node(20)
    bt2.root.right.right.left = Node(4)

    expected = [2, 7, 5, 6, 9, 5, 4]
    actual = tree_intersection(bt1, bt2)
    assert expected == actual
def test_with_empty_tree():
    bt1 = BinaryTree()
    bt1.root = Node(2)
    bt1.root.left = Node(7)
    bt1.root.right = Node(5)
    bt1.root.left.left = Node(2)
    bt1.root.left.right = Node(6)
    bt1.root.right.right = Node(9)
    bt1.root.left.right.left = Node(5)
    bt1.root.left.right.right = Node(11)
    bt1.root.right.right.left = Node(4)

    bt2 = BinaryTree()

    expected = []
    actual = tree_intersection(bt1, bt2)
    assert expected == actual
def test_all_nodes_equal(prepare_same_trees):
    bt1 = prepare_same_trees[0]
    bt2 = prepare_same_trees[1]
    assert tree_intersection(bt1, bt2) == [15, 10, 8, 13, 25, 18, 50]
def test_different_size(prepare_different_size):
    bt1 = prepare_different_size[0]
    bt2 = prepare_different_size[1]
    assert tree_intersection(bt1, bt2) == [15, 10]
def test_empty_tree(prepare_empty_tree):
    bt1 = prepare_empty_tree[0]
    bt2 = prepare_empty_tree[1]
    assert tree_intersection(bt1, bt2) == None
def test_no_insertion(prepare_no_insertion):
    bt1 = prepare_no_insertion[0]
    bt2 = prepare_no_insertion[1]
    assert tree_intersection(bt1, bt2) == None
def test_different_locations(prepare_different_nodes_locations):
    bt1 = prepare_different_nodes_locations[0]
    bt2 = prepare_different_nodes_locations[1]
    assert tree_intersection(bt1, bt2) == [15]
def test_tree_intersection_2(tree1, tree3):
    assert tree_intersection(tree1, tree3) == 'Tree 2 is empty'
def test_tree_intersection_1(tree1, tree2):
    assert tree_intersection(tree1,
                             tree2) == [100, 160, 125, 175, 200, 350, 500]
def test_tree_intersection_3(tree1, tree4):
    assert tree_intersection(tree1, tree4) == 'No Common Values'