Skip to content

Commit cb994fd

Browse files
committed
Add test with invalid backend content type
1 parent 25e28c5 commit cb994fd

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/test_aiohttp.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,35 @@ async def handler(request):
6969
assert africa["code"] == "AF"
7070

7171

72+
@pytest.mark.asyncio
73+
async def test_aiohttp_ignore_backend_content_type(event_loop, aiohttp_server):
74+
from aiohttp import web
75+
from gql.transport.aiohttp import AIOHTTPTransport
76+
77+
async def handler(request):
78+
return web.Response(text=query1_server_answer, content_type="text/plain")
79+
80+
app = web.Application()
81+
app.router.add_route("POST", "/", handler)
82+
server = await aiohttp_server(app)
83+
84+
url = server.make_url("/")
85+
86+
sample_transport = AIOHTTPTransport(url=url, timeout=10)
87+
88+
async with Client(transport=sample_transport,) as session:
89+
90+
query = gql(query1_str)
91+
92+
result = await session.execute(query)
93+
94+
continents = result["continents"]
95+
96+
africa = continents[0]
97+
98+
assert africa["code"] == "AF"
99+
100+
72101
@pytest.mark.asyncio
73102
async def test_aiohttp_cookies(event_loop, aiohttp_server):
74103
from aiohttp import web

0 commit comments

Comments
 (0)