Skip to content

Commit 4ba8b73

Browse files
Add wait_for_job_result configuration validation tests
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 7fdc164 commit 4ba8b73

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/test_polling.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,41 @@ async def run() -> None:
300300
asyncio.run(run())
301301

302302

303+
def test_wait_for_job_result_validates_configuration():
304+
with pytest.raises(HyperbrowserError, match="max_attempts must be at least 1"):
305+
wait_for_job_result(
306+
operation_name="invalid-wait-config",
307+
get_status=lambda: "completed",
308+
is_terminal_status=lambda value: value == "completed",
309+
fetch_result=lambda: {"ok": True},
310+
poll_interval_seconds=0.1,
311+
max_wait_seconds=1.0,
312+
max_status_failures=1,
313+
fetch_max_attempts=0,
314+
fetch_retry_delay_seconds=0.1,
315+
)
316+
317+
318+
def test_wait_for_job_result_async_validates_configuration():
319+
async def run() -> None:
320+
with pytest.raises(
321+
HyperbrowserError, match="poll_interval_seconds must be non-negative"
322+
):
323+
await wait_for_job_result_async(
324+
operation_name="invalid-async-wait-config",
325+
get_status=lambda: asyncio.sleep(0, result="completed"),
326+
is_terminal_status=lambda value: value == "completed",
327+
fetch_result=lambda: asyncio.sleep(0, result={"ok": True}),
328+
poll_interval_seconds=-0.1,
329+
max_wait_seconds=1.0,
330+
max_status_failures=1,
331+
fetch_max_attempts=1,
332+
fetch_retry_delay_seconds=0.1,
333+
)
334+
335+
asyncio.run(run())
336+
337+
303338
def test_polling_helpers_validate_retry_and_interval_configuration():
304339
with pytest.raises(HyperbrowserError, match="max_attempts must be at least 1"):
305340
retry_operation(

0 commit comments

Comments
 (0)