Пример #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'})