Skip to content

Commit 6a8ce08

Browse files
committed
New cursor test
1 parent e1bc630 commit 6a8ce08

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_cursor.py

+19
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,25 @@ async def test_cursor_context_manager(db, doc_col, docs):
270270
assert await cursor.close(ignore_missing=True) is False
271271

272272

273+
@pytest.mark.asyncio
274+
async def test_cursor_iteration(db, doc_col, docs):
275+
# Insert documents
276+
await asyncio.gather(*[doc_col.insert(doc) for doc in docs])
277+
278+
aql: AQL = db.aql
279+
cursor = await aql.execute(
280+
f"FOR d IN {doc_col.name} SORT d._key RETURN d",
281+
count=True,
282+
batch_size=2,
283+
ttl=1000,
284+
)
285+
doc_cnt = 0
286+
async with cursor as ctx:
287+
async for _ in ctx:
288+
doc_cnt += 1
289+
assert doc_cnt == len(docs)
290+
291+
273292
@pytest.mark.asyncio
274293
async def test_cursor_manual_fetch_and_pop(db, doc_col, docs):
275294
# Insert documents

0 commit comments

Comments
 (0)