Exemplo n.º 1
0
def test_client_can_build_media_object():
    query_builder = QueryBuilder()
    media_query = MediaQuery([("id", 2966)])
    media_query.body = "body"
    query, variables = query_builder.build(media_query)
    media = asMedia(client.request(query, variables)["Media"])
    assert media.title.english == "Spice and Wolf"
Exemplo n.º 2
0
def test_query_builder_can_build_media_query():
    query_builder = QueryBuilder()
    media_query = MediaQuery([("id", 2966)])
    media_query.body = "body"
    query, variables = query_builder.build(media_query)
    assert query == "query($id:Int){Media(id:$id){body}}" and variables == {
        "id": 2966
    }
Exemplo n.º 3
0
def test_query_builder_can_build_build_nested_media_query():
    query_builder = QueryBuilder()
    media_query = MediaQuery([("id_in", [2966, 5341])])
    media_query.body = "body"
    page_query = PageQuery(None, media_query)
    query, variables = query_builder.build(page_query)
    assert query == "query($id_in:[Int]){Page{media(id_in:$id_in){body}}}" and variables == {
        "id_in": [2966, 5341]
    }
Exemplo n.º 4
0
def test_query_builder_can_build_simple_query_with_one_argument():
    query_builder = QueryBuilder()
    media_query = MediaQuery([("id", -1)])
    media_query.body = "body"
    query, variables = query_builder.build(media_query)

    assert query == "query($id:Int){Media(id:$id){body}}" and len(
        variables) == 1 and variables == {
            "id": -1
        }
Exemplo n.º 5
0
def test_query_builder_can_build_simple_query_with_multiple_arguments():
    query_builder = QueryBuilder()
    media_query = MediaQuery([("id", -1), ("type", manga),
                              ("chapters_greater", 1)])
    media_query.body = "body"
    query, variables = query_builder.build(media_query)

    assert query == "query($id:Int,$type:MediaType,$chapters_greater:Int){Media(id:$id,type:$type,chapters_greater:$chapters_greater){body}}" and len(
        variables) == 3 and variables == {
            "id": -1,
            "type": manga,
            "chapters_greater": 1
        }
Exemplo n.º 6
0
def test_query_builder_raises_exception_when_multiple_keys_of_same_type_are_passed(
):
    query_builder = QueryBuilder()
    media_query = MediaQuery()
    with pytest.raises(KeyError):
        media_query.setArguments([("id", 1), ("id", 2)])