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)
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)
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]
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
def test_insert_root_node_with_auto_position(cur): root = insert_node(cur, None, 'folder', auto_position=True) delete_node(cur, root)