Skip to content

Commit c074e09

Browse files
committed
Remove tests for long contexts
1 parent 1be5a06 commit c074e09

File tree

1 file changed

+2
-72
lines changed

1 file changed

+2
-72
lines changed

tests/websockets/test_graphql_transport_ws.py

Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,12 +1071,7 @@ async def test_long_validation_concurrent_query(ws: WebSocketClient):
10711071
# we expect the second query to arrive first, because the
10721072
# first query is stuck in validation
10731073
response = await ws.receive_json()
1074-
assert (
1075-
response
1076-
== NextMessage(
1077-
id="sub2", payload={"data": {"conditionalFail": "Hey"}}
1078-
).as_dict()
1079-
)
1074+
assert_next(response, "sub2", {"conditionalFail": "Hey"})
10801075

10811076

10821077
async def test_long_validation_concurrent_subscription(ws: WebSocketClient):
@@ -1104,72 +1099,7 @@ async def test_long_validation_concurrent_subscription(ws: WebSocketClient):
11041099
# we expect the second query to arrive first, because the
11051100
# first operation is stuck in validation
11061101
response = await ws.receive_json()
1107-
assert (
1108-
response
1109-
== NextMessage(
1110-
id="sub2", payload={"data": {"conditionalFail": "Hey"}}
1111-
).as_dict()
1112-
)
1113-
1114-
1115-
async def test_long_custom_context(
1116-
ws: WebSocketClient, http_client_class: Type[HttpClient]
1117-
):
1118-
"""
1119-
Test that the websocket is not blocked evaluating the context
1120-
"""
1121-
if http_client_class in (FastAPIHttpClient, StarliteHttpClient, LitestarHttpClient):
1122-
pytest.skip("Client evaluates the context only once per connection")
1123-
1124-
counter = 0
1125-
1126-
async def slow_get_context(ctxt):
1127-
nonlocal counter
1128-
old = counter
1129-
counter += 1
1130-
if old == 0:
1131-
await asyncio.sleep(0.1)
1132-
ctxt["custom_value"] = "slow"
1133-
else:
1134-
ctxt["custom_value"] = "fast"
1135-
return ctxt
1136-
1137-
with patch("tests.http.context.get_context_async_inner", slow_get_context):
1138-
await ws.send_json(
1139-
SubscribeMessage(
1140-
id="sub1",
1141-
payload=SubscribeMessagePayload(query="query { valueFromContext }"),
1142-
).as_dict()
1143-
)
1144-
1145-
await ws.send_json(
1146-
SubscribeMessage(
1147-
id="sub2",
1148-
payload=SubscribeMessagePayload(
1149-
query="query { valueFromContext }",
1150-
),
1151-
).as_dict()
1152-
)
1153-
1154-
# we expect the second query to arrive first, because the
1155-
# first operation is stuck getting context
1156-
response = await ws.receive_json()
1157-
assert (
1158-
response
1159-
== NextMessage(
1160-
id="sub2", payload={"data": {"valueFromContext": "fast"}}
1161-
).as_dict()
1162-
)
1163-
1164-
response = await ws.receive_json()
1165-
if response == CompleteMessage(id="sub2").as_dict():
1166-
response = await ws.receive_json() # ignore the complete message
1167-
assert (
1168-
response
1169-
== NextMessage(
1170-
id="sub1", payload={"data": {"valueFromContext": "slow"}}
1171-
).as_dict()
1172-
)
1102+
assert_next(response, "sub2", {"conditionalFail": "Hey"})
11731103

11741104

11751105
async def test_task_error_handler(ws: WebSocketClient):

0 commit comments

Comments
 (0)