File: test_nested_input.py

package info (click to toggle)
python-gql 4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,900 kB
  • sloc: python: 21,677; makefile: 54
file content (40 lines) | stat: -rw-r--r-- 1,006 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pytest

from gql import Client
from gql.dsl import DSLQuery, DSLSchema, dsl_gql
from tests.nested_input.schema import NestedInputSchema


@pytest.fixture
def ds():
    return DSLSchema(NestedInputSchema)


@pytest.fixture
def client():
    return Client(schema=NestedInputSchema)


def test_nested_input(ds, client):
    query = dsl_gql(DSLQuery(ds.Query.echo.args(nested={"foo": 1})))
    assert client.execute(query) == {"echo": '{"foo": 1}'}


def test_nested_input_2(ds, client):
    query = dsl_gql(
        DSLQuery(ds.Query.echo.args(nested={"foo": 1, "child": {"foo": 2}}))
    )
    assert client.execute(query) == {"echo": '{"foo": 1, "child": {"foo": 2}}'}


def test_nested_input_3(ds, client):
    query = dsl_gql(
        DSLQuery(
            ds.Query.echo.args(
                nested={"foo": 1, "child": {"foo": 2, "child": {"foo": 3}}}
            )
        )
    )
    assert client.execute(query) == {
        "echo": '{"foo": 1, "child": {"foo": 2, "child": {"foo": 3}}}'
    }