File: test_introspection.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 (63 lines) | stat: -rw-r--r-- 2,085 bytes parent folder | download
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import pytest
from graphql import print_schema

from gql import Client

from .fixtures import make_starwars_transport

# Marking all tests in this file with the aiohttp marker
pytestmark = pytest.mark.aiohttp


@pytest.mark.asyncio
async def test_starwars_introspection_args(aiohttp_server):

    transport = await make_starwars_transport(aiohttp_server)

    # First fetch the schema from transport using default introspection query
    # We should receive descriptions in the schema but not deprecated input fields
    async with Client(
        transport=transport,
        fetch_schema_from_transport=True,
        introspection_args={
            "input_value_deprecation": False,
        },
    ) as session:

        schema_str = print_schema(session.client.schema)
        print(schema_str)

        assert '"""The number of stars this review gave, 1-5"""' in schema_str
        assert "deprecated_input_field" not in schema_str

    # Then fetch the schema from transport using an introspection query
    # without requesting descriptions
    # We should NOT receive descriptions in the schema
    async with Client(
        transport=transport,
        fetch_schema_from_transport=True,
        introspection_args={
            "descriptions": False,
            "input_value_deprecation": False,
        },
    ) as session:

        schema_str = print_schema(session.client.schema)
        print(schema_str)

        assert '"""The number of stars this review gave, 1-5"""' not in schema_str
        assert "deprecated_input_field" not in schema_str

    # Then fetch the schema from transport using and introspection query
    # requiring deprecated input fields
    # We should receive descriptions in the schema and deprecated input fields
    async with Client(
        transport=transport,
        fetch_schema_from_transport=True,
    ) as session:

        schema_str = print_schema(session.client.schema)
        print(schema_str)

        assert '"""The number of stars this review gave, 1-5"""' in schema_str
        assert "deprecated_input_field" in schema_str