diff --git a/tests/websockets/test_graphql_transport_ws.py b/tests/websockets/test_graphql_transport_ws.py index 78a3f3a0e3..17b9ca0af9 100644 --- a/tests/websockets/test_graphql_transport_ws.py +++ b/tests/websockets/test_graphql_transport_ws.py @@ -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. diff --git a/tests/websockets/test_graphql_ws.py b/tests/websockets/test_graphql_ws.py index 80cf07dced..6a07fb6ac4 100644 --- a/tests/websockets/test_graphql_ws.py +++ b/tests/websockets/test_graphql_ws.py @@ -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"}