Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make graphql_ws test less timing-sensitive. #2785

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/websockets/test_graphql_transport_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,9 @@ async def test_rejects_connection_params_not_unset(ws_raw: WebSocketClient):
ws.assert_reason("Invalid connection init payload")


# timings can sometimes fail currently. Until this test is rewritten when
# generator based subscriptions are implemented, mark it as flaky
@pytest.mark.flaky
async def test_subsciption_cancel_finalization_delay(ws: WebSocketClient):
# Test that when we cancel a subscription, the websocket isn't blocked
# while some complex finalization takes place.
Expand Down
16 changes: 10 additions & 6 deletions tests/websockets/test_graphql_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,17 @@ async def test_sends_keep_alive(aiohttp_app_client: HttpClient):
response = await ws.receive_json()
assert response["type"] == GQL_CONNECTION_ACK

response = await ws.receive_json()
assert response["type"] == GQL_CONNECTION_KEEP_ALIVE

response = await ws.receive_json()
assert response["type"] == GQL_CONNECTION_KEEP_ALIVE
# we can't be sure how many keep-alives exactly we
# get but they should be more than one.
keepalive_count = 0
while True:
response = await ws.receive_json()
if response["type"] == GQL_CONNECTION_KEEP_ALIVE:
keepalive_count += 1
else:
break
assert keepalive_count >= 1

response = await ws.receive_json()
assert response["type"] == GQL_DATA
assert response["id"] == "demo"
assert response["payload"]["data"] == {"echo": "Hi"}
Expand Down