示例#1
0
def test_insert_child(mock, trans, cur):
    node = Node(trans, 1)
    properties = {'type': 'new_child'}
    node.insert_child(properties)
    mock.assert_called_with(cur,
                            node.id,
                            properties,
                            position=-1,
                            auto_position=True)
示例#2
0
def test_move(mock, trans, cur):
    node = Node(trans, 1)
    target_node = Node(trans, 2)
    node.move(target_node)
    mock.assert_called_with(cur,
                            node.id,
                            target_node.id,
                            position=-1,
                            auto_position=True)
示例#3
0
def test_it_wont_compare_other_types(trans, nd1, nd2):
    node = Node(trans, nd1.id)
    assert node != nd1
示例#4
0
def test_insert_child(mock, trans, cur):
    node = Node(trans, 1)
    properties = {'type': 'new_child'}
    node.insert_child(properties)
    mock.assert_called_with(cur, node.id, properties, position=-1,
                            auto_position=True)
示例#5
0
def test_it_compares_other_nodes(trans, nd1, nd2):
    node1a = Node(trans, nd1.id)
    node1b = Node(trans, nd1.id)
    node2 = Node(trans, nd2.id)
    assert node1a == node1b
    assert node1a != node2
示例#6
0
def test_basic_representation(trans, root):
    node = Node(trans, root.id)
    assert repr(node) == '<Node id={}>'.format(root.id, root.position)
示例#7
0
def test_get_descendants(trans, nd2_1, nd2_1_1, nd2_leaf):
    node = Node(trans, nd2_1.id)
    descendants = [Node(trans, nd2_1_1.id), Node(trans, nd2_leaf.id)]
    assert node.descendants == descendants
示例#8
0
def test_get_position(trans, nd3):
    node = Node(trans, nd3.id)
    assert node.position == nd3.position
示例#9
0
def test_get_children_count(trans, cur, root):
    node = Node(trans, root)
    assert len(node) == core.get_children_count(cur, root.id)
示例#10
0
def test_has_children(trans, nd2, nd2_leaf):
    node = Node(trans, nd2.id)
    node2_leaf = Node(trans, nd2_leaf.id)
    assert node.has_children
    assert not node2_leaf.has_children
示例#11
0
def test_swap_position(mock, trans, cur):
    node1 = Node(trans, 1)
    node2 = Node(trans, 2)
    node1.swap_position(node2)
    mock.assert_called_with(cur, node1.id, node2.id)
示例#12
0
def test_get_recursive_properties(mock, trans, cur):
    node = Node(trans, 1)
    node.recursive_properties
    mock.assert_called_with(cur, node.id)
示例#13
0
def test_get_parent_returns_none_for_root(trans, root):
    assert Node(trans, root.id).parent is None
示例#14
0
def test_swap_position(mock, trans, cur):
    node1 = Node(trans, 1)
    node2 = Node(trans, 2)
    node1.swap_position(node2)
    mock.assert_called_with(cur, node1.id, node2.id)
示例#15
0
def test_move(mock, trans, cur):
    node = Node(trans, 1)
    target_node = Node(trans, 2)
    node.move(target_node)
    mock.assert_called_with(cur, node.id, target_node.id, position=-1,
                            auto_position=True)
示例#16
0
def test_delete(mock, trans, cur):
    node = Node(trans, 1)
    node.delete()
    mock.assert_called_with(cur, node.id)
示例#17
0
def test_hash(trans, nd1, nd2):
    node1a = Node(trans, nd1.id)
    node1b = Node(trans, nd1.id)
    node2 = Node(trans, nd2.id)
    assert hash(node1a) == hash(node1b)
    assert hash(node1a) != hash(node2)
示例#18
0
def test_title_representation(trans, nd1):
    node = Node(trans, nd1.id)
    expected = "<Node id={}, title='Node 1'>".format(nd1.id)
    assert repr(node) == expected
示例#19
0
def test_get_parent(trans, nd2_1_1, nd2_leaf):
    node = Node(trans, nd2_leaf.id)
    parent = node.parent
    assert parent.id == nd2_1_1.id
示例#20
0
def test_get_inherited_properties(mock, trans, cur):
    node = Node(trans, 1)
    node.inherited_properties
    mock.assert_called_with(cur, node.id)
示例#21
0
def test_get_properties(trans, nd3):
    node = Node(trans, nd3.id)
    assert node.properties == nd3.properties
示例#22
0
def test_set_properties(mock, trans, cur):
    node = Node(trans, 1)
    node.set_properties({'foo': 'bar'})
    mock.assert_called_with(cur, node.id, {'foo': 'bar'})
示例#23
0
def test_get_children(trans, nd2, nd2_1):
    node = Node(trans, nd2.id)
    children = [Node(trans, nd2_1.id)]
    assert node.children == children
示例#24
0
def test_delete(mock, trans, cur):
    node = Node(trans, 1)
    node.delete()
    mock.assert_called_with(cur, node.id)
示例#25
0
def test_get_ancestors(trans, root, nd2, nd2_1):
    node = Node(trans, nd2_1.id)
    ancestors = [Node(trans, nd2.id), Node(trans, root.id)]
    assert node.ancestors == ancestors
示例#26
0
def test_set_position(mock, trans, cur):
    node = Node(trans, 1)
    node.set_position(1337)
    mock.assert_called_with(cur, node.id, 1337, auto_position=True)
示例#27
0
def test_set_position(mock, trans, cur):
    node = Node(trans, 1)
    node.set_position(1337)
    mock.assert_called_with(cur, node.id, 1337, auto_position=True)
示例#28
0
def test_get_child_at_position(mock, trans, cur):
    node = Node(trans, 1)
    node.get_child_at_position(2)
    mock.assert_called_with(cur, 1, 2)
示例#29
0
def test_get_child_at_position(mock, trans, cur):
    node = Node(trans, 1)
    node.get_child_at_position(2)
    mock.assert_called_with(cur, 1, 2)
示例#30
0
def test_set_properties(mock, trans, cur):
    node = Node(trans, 1)
    node.set_properties({'foo': 'bar'})
    mock.assert_called_with(cur, node.id, {'foo': 'bar'})