Skip to content

Commit 258cc64

Browse files
committed
polish(incremental): improve IncrementalPublisher finish test
Replicates graphql/graphql-js@c78bc1d
1 parent 053f245 commit 258cc64

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

tests/execution/test_stream.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,19 +2395,15 @@ async def finishes_async_iterable_when_finished_generator_is_closed():
23952395
async def iterable(_info):
23962396
nonlocal finished
23972397
try:
2398-
for i in range(3): # pragma: no cover exit
2399-
yield friends[i]
2398+
yield None
24002399
finally:
24012400
finished = True
24022401

24032402
document = parse(
24042403
"""
24052404
query {
2406-
friendList @stream(initialCount: 1) {
2405+
friendList @stream(initialCount: 0) {
24072406
id
2408-
... @defer {
2409-
name
2410-
}
24112407
}
24122408
}
24132409
"""
@@ -2421,20 +2417,21 @@ async def iterable(_info):
24212417

24222418
result1 = execute_result.initial_result
24232419
assert result1 == {
2424-
"data": {"friendList": [{"id": "1"}]},
2420+
"data": {"friendList": []},
24252421
"pending": [
2426-
{"id": "0", "path": ["friendList", 0]},
2427-
{"id": "1", "path": ["friendList"]},
2422+
{"id": "0", "path": ["friendList"]},
24282423
],
24292424
"hasNext": True,
24302425
}
24312426

2427+
assert not finished
2428+
24322429
# we need to run the iterator once before we can close it
24332430
result2 = await anext(iterator)
24342431
assert result2 == {
2435-
"incremental": [{"data": {"name": "Luke"}, "id": "0"}],
2432+
"incremental": [{"items": [None], "id": "0"}],
24362433
"completed": [{"id": "0"}],
2437-
"hasNext": True,
2434+
"hasNext": False,
24382435
}
24392436

24402437
await iterator.aclose()

0 commit comments

Comments
 (0)