Ejemplo n.º 1
0
def test_query_param_declaration():
    q, _ = query.Query("x", Project, Project.name > "name").format_top("y")
    assert q.startswith("query yPyApi($param_0: String!){x")

    q, _ = query.Query("x", Project, (Project.name > "name")
                       & (Project.uid == 42)).format_top("y")
    assert q.startswith("query yPyApi($param_0: String!, $param_1: ID!){x")
Ejemplo n.º 2
0
def test_query_where():
    q, p = query.Query("x", Project, Project.name > "name").format()
    assert q.startswith("x(where: {name_gt: $param_0}){")
    assert p == {"param_0": ("name", Project.name)}

    q, p = query.Query("x", Project, (Project.name != "name") &
                       (Project.uid <= 42)).format()
    assert q.startswith(
        "x(where: {AND: [{name_not: $param_0}, {id_lte: $param_1}]}")
    assert p == {
        "param_0": ("name", Project.name),
        "param_1": (42, Project.uid)
    }
Ejemplo n.º 3
0
def format(*args, **kwargs):
    return query.Query(*args, **kwargs).format()[0]
Ejemplo n.º 4
0
def test_query_order_by():
    q, _ = query.Query("x", Project, order_by=Project.name.asc).format()
    assert q.startswith("x(orderBy: name_ASC){")

    q, _ = query.Query("x", Project, order_by=Project.uid.desc).format()
    assert q.startswith("x(orderBy: id_DESC){")
Ejemplo n.º 5
0
def test_query_subquery():
    assert format("x", query.Query("sub", Project)).startswith("x{sub{")
    assert format("x", query.Query("bus", Project)).startswith("x{bus{")