Example #1
0
def test_insert_nodes_at_highest_position(cur, root):
    highest_position = find_highest_position(cur, root)
    node4 = insert_node(cur, root, position=None, auto_position=True)
    node5 = insert_node(cur, root, position=-1, auto_position=True)
    assert node4.position == highest_position + 1
    assert node5.position == highest_position + 2

    delete_node(cur, node4)
    delete_node(cur, node5)
Example #2
0
def test_insert_nodes_at_highest_position(cur, root):
    highest_position = find_highest_position(cur, root)
    node4 = insert_node(cur, root, position=None, auto_position=True)
    node5 = insert_node(cur, root, position=-1, auto_position=True)
    assert node4.position == highest_position + 1
    assert node5.position == highest_position + 2

    delete_node(cur, node4)
    delete_node(cur, node5)
Example #3
0
def get_or_create_nd(cur, parent, properties, *args, **kwargs):
    xtype = properties.get('type')
    node_id = node_ids.get(xtype, None)
    if node_id is None:
        node = insert_node(cur, parent, properties=properties, *args, **kwargs)
        node_ids[xtype] = node.id
        return node
    return get_node(cur, node_id)
Example #4
0
def get_or_create_nd(cur, parent, properties, *args, **kwargs):
    xtype = properties.get('type')
    node_id = node_ids.get(xtype, None)
    if node_id is None:
        node = insert_node(cur, parent, properties=properties, *args, **kwargs)
        node_ids[xtype] = node.id
        return node
    return get_node(cur, node_id)
Example #5
0
def test_insert_node_at_specific_position(cur, root):
    node0 = insert_node(cur, root, position=0, auto_position=True)
    positions = map(lambda n: n.position, get_children(cur, root))
    assert node0.position == 0
    assert list(positions) == [0, 1, 2, 4]
Example #6
0
def test_insert_node_starts_counting_at_zero(cur, nd1):
    nd1_1 = insert_node(cur, nd1, 'nd1-1', auto_position=True)
    assert nd1_1.position == 0
Example #7
0
def test_insert_root_node_with_auto_position(cur):
    root = insert_node(cur, None, 'folder', auto_position=True)
    delete_node(cur, root)
Example #8
0
def test_insert_root_node_with_auto_position(cur):
    root = insert_node(cur, None, 'folder', auto_position=True)
    delete_node(cur, root)
Example #9
0
def test_insert_node_at_specific_position(cur, root):
    node0 = insert_node(cur, root, position=0, auto_position=True)
    positions = map(lambda n: n.position, get_children(cur, root))
    assert node0.position == 0
    assert list(positions) == [0, 1, 2, 4]
Example #10
0
def test_insert_node_starts_counting_at_zero(cur, nd1):
    nd1_1 = insert_node(cur, nd1, 'nd1-1', auto_position=True)
    assert nd1_1.position == 0