mirror of
https://github.com/anomalyco/opencode-sdk-python.git
synced 2026-04-29 21:20:08 +00:00
feat(api): update via SDK Studio
This commit is contained in:
parent
6d8571b73d
commit
d70071b1fc
6 changed files with 84 additions and 35 deletions
|
|
@ -24,6 +24,7 @@ from pydantic import ValidationError
|
|||
from opencode_ai import Opencode, AsyncOpencode, APIResponseValidationError
|
||||
from opencode_ai._types import Omit
|
||||
from opencode_ai._models import BaseModel, FinalRequestOptions
|
||||
from opencode_ai._streaming import Stream, AsyncStream
|
||||
from opencode_ai._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError
|
||||
from opencode_ai._base_client import (
|
||||
DEFAULT_TIMEOUT,
|
||||
|
|
@ -624,6 +625,17 @@ class TestOpencode:
|
|||
with pytest.raises(TypeError, match=r"max_retries cannot be None"):
|
||||
Opencode(base_url=base_url, _strict_response_validation=True, max_retries=cast(Any, None))
|
||||
|
||||
@pytest.mark.respx(base_url=base_url)
|
||||
def test_default_stream_cls(self, respx_mock: MockRouter) -> None:
|
||||
class Model(BaseModel):
|
||||
name: str
|
||||
|
||||
respx_mock.post("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
|
||||
|
||||
stream = self.client.post("/foo", cast_to=Model, stream=True, stream_cls=Stream[Model])
|
||||
assert isinstance(stream, Stream)
|
||||
stream.response.close()
|
||||
|
||||
@pytest.mark.respx(base_url=base_url)
|
||||
def test_received_text_for_expected_json(self, respx_mock: MockRouter) -> None:
|
||||
class Model(BaseModel):
|
||||
|
|
@ -1390,6 +1402,18 @@ class TestAsyncOpencode:
|
|||
with pytest.raises(TypeError, match=r"max_retries cannot be None"):
|
||||
AsyncOpencode(base_url=base_url, _strict_response_validation=True, max_retries=cast(Any, None))
|
||||
|
||||
@pytest.mark.respx(base_url=base_url)
|
||||
@pytest.mark.asyncio
|
||||
async def test_default_stream_cls(self, respx_mock: MockRouter) -> None:
|
||||
class Model(BaseModel):
|
||||
name: str
|
||||
|
||||
respx_mock.post("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
|
||||
|
||||
stream = await self.client.post("/foo", cast_to=Model, stream=True, stream_cls=AsyncStream[Model])
|
||||
assert isinstance(stream, AsyncStream)
|
||||
await stream.response.aclose()
|
||||
|
||||
@pytest.mark.respx(base_url=base_url)
|
||||
@pytest.mark.asyncio
|
||||
async def test_received_text_for_expected_json(self, respx_mock: MockRouter) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue