def test_branch_split():
    branch_node = BEpsilonTree.BranchNode(buffer=[2, 3, 4, 5, 6, 7, 8, 9], keys=[3, 6, 8], children=[1, 2, 3, 4])
    left_node, right_node, median = branch_node.split()
    assert median == 6
    assert left_node.children == [1, 2]
    assert left_node.buffer == [2, 3, 4, 5]
    assert right_node.children == [3, 4]
    assert right_node.buffer == [6, 7, 8, 9]
def test_branch_pop_most_pending():
    branch_node = BEpsilonTree.BranchNode(buffer=[2, 3, 4, 5, 6, 7, 8, 9], keys=[3, 6, 8], children=[1, 2, 3, 4])
    child_ptr, items = branch_node.pop_most_pending()
    assert items == [3, 4, 5, 6]
    assert child_ptr == 2
    assert branch_node.buffer == [2, 7, 8, 9]
def test_branch_node_get_child():
    branch_node = BEpsilonTree.BranchNode(buffer=[], keys=[3, 5, 8], children=[1, 2, 3, 4])
    children = []
    for i in range(10):
        children.append(branch_node.get_child(i))
    assert children == [1, 1, 1, 2, 2, 3, 3, 3, 4, 4]
def test_branch_node_replace_child():
    branch_node = BEpsilonTree.BranchNode(buffer=[], keys=[3, 5, 8], children=[1, 2, 3, 4])
    branch_node.replace_child(2, 2, 5, 4)
    assert branch_node.keys == [3, 4, 5, 8]
    assert branch_node.children == [1, 2, 5, 3, 4]
def test_branch_node_add_and_contains():
    branch_node = BEpsilonTree.BranchNode(buffer=[1, 2, 3], keys=[1], children=[1, 2])
    assert 2 in branch_node
    branch_node.add(5)
    assert 5 in branch_node