def test_node_branch_insert_greater(branch_node: binary_tree.Node): """ GIVEN branch node and value that is greater than the node value WHEN insert is called with the value THEN the right child node insert is called with the value. """ value = 1 branch_node.insert(value) branch_node.right.insert.assert_called_once_with(value)
def test_node_branch_insert_equal(branch_node: binary_tree.Node): """ GIVEN branch node and value that is equal to the node value WHEN insert is called with the value THEN the left child node insert is called with the value. """ value = 0 branch_node.insert(value) branch_node.left.insert.assert_called_once_with(value)
def test_node_leaf_insert_greater(leaf_node: binary_tree.Node): """ GIVEN leaf node and value that is greater than the node value WHEN insert is called with the value THEN a new leaf node is inserted on the right with the value. """ value = 1 leaf_node.insert(value) assert leaf_node.right is not None assert leaf_node.right.value == value assert leaf_node.right.left is None assert leaf_node.right.right is None
def test_node_leaf_insert_equal(leaf_node: binary_tree.Node): """ GIVEN leaf node and value that is equal to the node value WHEN insert is called with the value THEN a new leaf node is inserted on the left with the value. """ value = 0 leaf_node.insert(value) assert leaf_node.left is not None assert leaf_node.left.value == value assert leaf_node.left.left is None assert leaf_node.left.right is None