Skip to content

Commit d220d54

Browse files
Cover zero-wait timeout behavior after first status check
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 5f296ec commit d220d54

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/test_polling.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@ def test_poll_until_terminal_status_allows_immediate_terminal_on_zero_max_wait()
4646
assert status == "completed"
4747

4848

49+
def test_poll_until_terminal_status_zero_max_wait_times_out_after_first_check():
50+
attempts = {"count": 0}
51+
52+
def get_status() -> str:
53+
attempts["count"] += 1
54+
return "running"
55+
56+
with pytest.raises(
57+
HyperbrowserTimeoutError, match="Timed out waiting for sync zero wait timeout"
58+
):
59+
poll_until_terminal_status(
60+
operation_name="sync zero wait timeout",
61+
get_status=get_status,
62+
is_terminal_status=lambda value: value == "completed",
63+
poll_interval_seconds=0.0001,
64+
max_wait_seconds=0,
65+
)
66+
67+
assert attempts["count"] == 1
68+
69+
4970
def test_poll_until_terminal_status_times_out():
5071
with pytest.raises(
5172
HyperbrowserTimeoutError, match="Timed out waiting for sync timeout"
@@ -168,6 +189,31 @@ async def run() -> None:
168189
asyncio.run(run())
169190

170191

192+
def test_async_poll_until_terminal_status_zero_max_wait_times_out_after_first_check():
193+
async def run() -> None:
194+
attempts = {"count": 0}
195+
196+
async def get_status() -> str:
197+
attempts["count"] += 1
198+
return "running"
199+
200+
with pytest.raises(
201+
HyperbrowserTimeoutError,
202+
match="Timed out waiting for async zero wait timeout",
203+
):
204+
await poll_until_terminal_status_async(
205+
operation_name="async zero wait timeout",
206+
get_status=get_status,
207+
is_terminal_status=lambda value: value == "completed",
208+
poll_interval_seconds=0.0001,
209+
max_wait_seconds=0,
210+
)
211+
212+
assert attempts["count"] == 1
213+
214+
asyncio.run(run())
215+
216+
171217
def test_async_poll_until_terminal_status_retries_transient_status_errors():
172218
async def run() -> None:
173219
attempts = {"count": 0}

0 commit comments

Comments
 (0)