Esempio n. 1
0
def ensure_free_position(cur, node, position):
    """
    Move siblings away to have a free slot at ``position`` in the
    children of ``node``.

    :param node:
    :type node: Node or int
    :param int position:
    """
    try:
        get_node_at_position(cur, node, position)
        node_exists_at_position = True
    except ValueError:
        node_exists_at_position = False

    if node_exists_at_position:
        shift_positions(cur, node, position, +1)
Esempio n. 2
0
def ensure_free_position(cur, node, position):
    """
    Move siblings away to have a free slot at ``position`` in the
    children of ``node``.

    :param node:
    :type node: Node or int
    :param int position:
    """
    try:
        get_node_at_position(cur, node, position)
        node_exists_at_position = True
    except ValueError:
        node_exists_at_position = False

    if node_exists_at_position:
        shift_positions(cur, node, position, +1)
Esempio n. 3
0
def test_get_node_at_position_non_existing(cur, root, nd3):
    with pytest.raises(ValueError):
        get_node_at_position(cur, root, -1)
    with pytest.raises(ValueError):
        get_node_at_position(cur, str(uuid.uuid4()), 1)
Esempio n. 4
0
def test_get_node_at_position(cur, root, nd3):
    node = get_node_at_position(cur, root, nd3.position)
    assert node.position == nd3.position
Esempio n. 5
0
def test_get_node_at_position_non_existing(cur, root, nd3):
    with pytest.raises(ValueError):
        get_node_at_position(cur, root, -1)
    with pytest.raises(ValueError):
        get_node_at_position(cur, -1, 1)
Esempio n. 6
0
def test_get_node_at_position(cur, root, nd3):
    node = get_node_at_position(cur, root, nd3.position)
    assert node.position == nd3.position