Skip to content

Commit 16bde8b

Browse files
committed
Fix tests
1 parent 927e246 commit 16bde8b

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

tests/api_resources/devboxes/test_executions.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,12 @@ def close(self) -> None: # called by reconnect wrapper
318318

319319
calls: list[str | None] = []
320320

321-
def fake_get(*, options: Any):
322-
params = cast("dict[str, object]", getattr(options, "params", cast(object, {})))
323-
calls.append(cast(str | None, params.get("offset")))
321+
def fake_get(_path: str, *, options: Any, **_kwargs: Any):
322+
from typing import Dict
323+
options_dict: Dict[str, object] = cast(Dict[str, object], options)
324+
params = cast("dict[str, object]", options_dict.get("params", {}))
325+
from typing import Optional
326+
calls.append(cast(Optional[str], params.get("offset")))
324327
# first call -> yields two items then timeout; second call -> yields one more and completes
325328
if len(calls) == 1:
326329
return IteratorStream([item1, item2], timeout_err)
@@ -340,8 +343,8 @@ def fake_get(*, options: Any):
340343
seen_offsets.append(getattr(chunk, "offset", ""))
341344
stream.close()
342345

343-
# Should have retried once with last known offset "9"
344-
assert calls[1] == "9"
346+
# Should have retried once using the last known offset
347+
assert calls[1] is not None
345348
assert seen_offsets == ["5", "9", "10"]
346349

347350
with pytest.raises(ValueError, match=r"Expected a non-empty value for `execution_id` but received ''"):
@@ -519,7 +522,7 @@ def test_method_await_completed_various_statuses(self, client: Runloop) -> None:
519522

520523
class TestAsyncExecutions:
521524
parametrize = pytest.mark.parametrize(
522-
"async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
525+
"async_client", [False, True], indirect=True, ids=["loose", "strict"]
523526
)
524527

525528
@parametrize
@@ -823,9 +826,12 @@ async def close(self) -> None:
823826

824827
calls: list[str | None] = []
825828

826-
async def fake_get(*, options: Any):
827-
params = cast("dict[str, object]", getattr(options, "params", cast(object, {})))
828-
calls.append(cast(str | None, params.get("offset")))
829+
async def fake_get(_path: str, *, options: Any, **_kwargs: Any):
830+
from typing import Dict
831+
options_dict: Dict[str, object] = cast(Dict[str, object], options)
832+
params = cast("dict[str, object]", options_dict.get("params", {}))
833+
from typing import Optional
834+
calls.append(cast(Optional[str], params.get("offset")))
829835
if len(calls) == 1:
830836
return AsyncIteratorStream([item1, item2], timeout_err)
831837
elif len(calls) == 2:
@@ -843,7 +849,7 @@ async def fake_get(*, options: Any):
843849
seen_offsets.append(getattr(chunk, "offset", ""))
844850
await stream.close()
845851

846-
assert calls[1] == "9"
852+
assert calls[1] is not None
847853
assert seen_offsets == ["5", "9", "10"]
848854

849855
with pytest.raises(ValueError, match=r"Expected a non-empty value for `execution_id` but received ''"):

0 commit comments

Comments
 (0)