Skip to content

Commit ce9f233

Browse files
committed
Add test for operationName
1 parent 2d8f663 commit ce9f233

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/test_websocket_subscription.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,34 @@ async def test_websocket_subscription_slow_consumer(
320320
assert count == -1
321321

322322

323+
@pytest.mark.asyncio
324+
@pytest.mark.parametrize("server", [server_countdown], indirect=True)
325+
@pytest.mark.parametrize("subscription_str", [countdown_subscription_str])
326+
async def test_websocket_subscription_with_operation_name(
327+
event_loop, client_and_server, subscription_str
328+
):
329+
330+
session, server = client_and_server
331+
332+
count = 10
333+
subscription = gql(subscription_str.format(count=count))
334+
335+
async for result in session.subscribe(
336+
subscription, operation_name="CountdownSubscription"
337+
):
338+
339+
number = result["number"]
340+
print(f"Number received: {number}")
341+
342+
assert number == count
343+
count -= 1
344+
345+
assert count == -1
346+
347+
# Check that the query contains the operationName
348+
assert '"operationName": "CountdownSubscription"' in logged_messages[0]
349+
350+
323351
WITH_KEEPALIVE = True
324352

325353

0 commit comments

Comments
 (0)