Beispiel #1
0
def test_equality():
    tree1 = Tree("field_name").start("some_node")
    tree2 = Tree("field_name").start("some_node")

    assert tree1 == tree2

    tree1 = tree1.list(1)

    assert tree1 != tree2

    assert tree1 != object()
Beispiel #2
0
def test_factory():
    tree: Tree = Tree("field_name").start("node")

    factory: Callable[[], Tree] = tree.get_factory()
    new_tree: Tree = factory()

    assert new_tree == tree

    tree = tree.list(1)

    assert new_tree != tree
Beispiel #3
0
def test_factory_alteration():
    tree: Tree = Tree("field_name").start("node")

    factory: Callable[[], Tree] = tree.get_factory()
    new_tree: Tree = factory()

    assert new_tree == tree

    new_tree = new_tree.list(1)
    new_new_tree: Tree = factory()

    assert new_new_tree == tree
Beispiel #4
0
def test_tree():
    tree = Tree("field_name")
    assert str(tree) == "field:field_name"
Beispiel #5
0
def test_list_prefix():
    tree = Tree("field_name").list(1).prefix("some_prefix_")
    assert str(tree) == "field:field_name^list:1^prefix:some_prefix_"
Beispiel #6
0
def test_start():
    tree = Tree("field_name").start("some_node")
    assert str(tree) == "field:field_name^start:some_node"
Beispiel #7
0
def test_list():
    tree = Tree("field_name").list(1)
    assert str(tree) == "field:field_name^list:1"
Beispiel #8
0
def test_tree():
    tree = Tree("somefield")
    query = Query(Collection.ABILITY).tree(tree)

    assert query.parameters == {"c:tree": [str(tree)]}