Skip to content

Commit 46f9947

Browse files
Add pagination metadata type validation regression tests
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 2b7628f commit 46f9947

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/test_polling.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,23 @@ def test_collect_paginated_results_raises_on_invalid_page_batch_values():
317317
)
318318

319319

320+
def test_collect_paginated_results_raises_on_invalid_page_batch_types():
321+
with pytest.raises(
322+
HyperbrowserPollingError,
323+
match="Invalid current page batch for sync paginated invalid types",
324+
):
325+
collect_paginated_results(
326+
operation_name="sync paginated invalid types",
327+
get_next_page=lambda page: {"current": "1", "total": 2, "items": []},
328+
get_current_page_batch=lambda response: response["current"],
329+
get_total_page_batches=lambda response: response["total"],
330+
on_page_success=lambda response: None,
331+
max_wait_seconds=1.0,
332+
max_attempts=2,
333+
retry_delay_seconds=0.0001,
334+
)
335+
336+
320337
def test_collect_paginated_results_async_times_out():
321338
async def run() -> None:
322339
with pytest.raises(
@@ -377,6 +394,28 @@ async def run() -> None:
377394
asyncio.run(run())
378395

379396

397+
def test_collect_paginated_results_async_raises_on_invalid_page_batch_types():
398+
async def run() -> None:
399+
with pytest.raises(
400+
HyperbrowserPollingError,
401+
match="Invalid total page batches for async paginated invalid types",
402+
):
403+
await collect_paginated_results_async(
404+
operation_name="async paginated invalid types",
405+
get_next_page=lambda page: asyncio.sleep(
406+
0, result={"current": 1, "total": "2", "items": []}
407+
),
408+
get_current_page_batch=lambda response: response["current"],
409+
get_total_page_batches=lambda response: response["total"],
410+
on_page_success=lambda response: None,
411+
max_wait_seconds=1.0,
412+
max_attempts=2,
413+
retry_delay_seconds=0.0001,
414+
)
415+
416+
asyncio.run(run())
417+
418+
380419
def test_wait_for_job_result_returns_fetched_value():
381420
status_values = iter(["running", "completed"])
382421

0 commit comments

Comments
 (0)