Skip to content

Commit

Permalink
Add test for client_session_args and connector_owner_false
Browse files Browse the repository at this point in the history
  • Loading branch information
leszekhanusz committed Jul 14, 2024
1 parent ddcc77f commit 05e61b8
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test_aiohttp_websocket_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,44 @@ async def test_aiohttp_websocket_simple_query_with_extensions(
execution_result = await session.execute(query, get_execution_result=True)

assert execution_result.extensions["key1"] == "val1"


@pytest.mark.asyncio
@pytest.mark.parametrize("server", [server1_answers], indirect=True)
async def test_aiohttp_websocket_connector_owner_false(event_loop, server):
from aiohttp import TCPConnector
from gql.transport.aiohttp_websockets import AIOHTTPWebsocketsTransport

url = f"ws://{server.hostname}:{server.port}/graphql"
print(f"url = {url}")

connector = TCPConnector()
transport = AIOHTTPWebsocketsTransport(
url=url,
timeout=10,
client_session_args={
"connector": connector,
"connector_owner": False,
},
)

for _ in range(2):
async with Client(transport=transport) as session:

query1 = gql(query1_str)

result = await session.execute(query1)

print("Client received:", result)

assert isinstance(result, Dict)

continents = result["continents"]
africa = continents[0]

assert africa["code"] == "AF"

# Check client is disconnect here
assert transport.websocket is None

await connector.close()

0 comments on commit 05e61b8

Please sign in to comment.