Beispiel #1
0
def test_invalid_variable():
    q = Query(
        variables__bazaar=Variable(),
    ).bind(request=req('get'))

    query2 = Query(
        variables__bazaar=Variable(),
    ).bind(request=req('get', **{q.advanced_query_param():'not_bazaar=asd'}))
    with pytest.raises(QueryException) as e:
        query2.to_q()
    assert 'Unknown variable "not_bazaar"' in str(e)
Beispiel #2
0
def test_invalid_value():
    q = Query(
        variables__bazaar=Variable.integer(
            value_to_q=lambda variable, op, value_string_or_f: None
        ),
    ).bind(request=req('get'))
    request = req('get', **{q.advanced_query_param(): 'bazaar=asd'})

    query2 = Query(
        variables__bazaar=Variable.integer(
            value_to_q=lambda variable, op, value_string_or_f: None
        ),
    ).bind(request=request)
    with pytest.raises(QueryException) as e:
        query2.to_q()
    assert 'Unknown value "asd" for variable "bazaar"' in str(e)