diff --git a/.stats.yml b/.stats.yml index 9aa0349..aea62f4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 40 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/plastic-labs%2Fhoncho-e4c301de216e3c01c130dfbf82f7d5272939867cc4b452aa00d6f0e081767bec.yml +configured_endpoints: 41 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/plastic-labs%2Fhoncho-9c89a1623da5f8289d05c3c8a8fa7778d7d89f8679e4e8a3589c1cb2735c70aa.yml diff --git a/README.md b/README.md index 324c468..200f918 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ client = Honcho( ) app = client.apps.create( - name="name", + name="x", ) print(app.id) ``` @@ -62,7 +62,7 @@ client = AsyncHoncho( async def main() -> None: app = await client.apps.create( - name="name", + name="x", ) print(app.id) @@ -169,7 +169,7 @@ client = Honcho() try: client.apps.create( - name="name", + name="x", ) except honcho.APIConnectionError as e: print("The server could not be reached") @@ -214,7 +214,7 @@ client = Honcho( # Or, configure per-request: client.with_options(max_retries=5).apps.create( - name="name", + name="x", ) ``` @@ -239,7 +239,7 @@ client = Honcho( # Override per-request: client.with_options(timeout=5.0).apps.create( - name="name", + name="x", ) ``` @@ -282,7 +282,7 @@ from honcho import Honcho client = Honcho() response = client.apps.with_raw_response.create( - name="name", + name="x", ) print(response.headers.get('X-My-Header')) @@ -302,7 +302,7 @@ To stream the response body, use `.with_streaming_response` instead, which requi ```python with client.apps.with_streaming_response.create( - name="name", + name="x", ) as response: print(response.headers.get("X-My-Header")) diff --git a/api.md b/api.md index d8a2cfe..2a88fcd 100644 --- a/api.md +++ b/api.md @@ -67,7 +67,7 @@ Methods: Types: ```python -from honcho.types.apps.users.sessions import Message, PageMessage +from honcho.types.apps.users.sessions import Message, PageMessage, MessageBatchResponse ``` Methods: @@ -75,6 +75,7 @@ Methods: - client.apps.users.sessions.messages.create(session_id, \*, app_id, user_id, \*\*params) -> Message - client.apps.users.sessions.messages.update(message_id, \*, app_id, user_id, session_id, \*\*params) -> Message - client.apps.users.sessions.messages.list(session_id, \*, app_id, user_id, \*\*params) -> SyncPage[Message] +- client.apps.users.sessions.messages.batch(session_id, \*, app_id, user_id, \*\*params) -> MessageBatchResponse - client.apps.users.sessions.messages.get(message_id, \*, app_id, user_id, session_id) -> Message #### Metamessages diff --git a/src/honcho/resources/apps/users/collections/collections.py b/src/honcho/resources/apps/users/collections/collections.py index 847bec5..46a2bf7 100644 --- a/src/honcho/resources/apps/users/collections/collections.py +++ b/src/honcho/resources/apps/users/collections/collections.py @@ -65,7 +65,7 @@ def create( *, app_id: str, name: str, - metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, + metadata: Dict[str, object] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -358,7 +358,7 @@ async def create( *, app_id: str, name: str, - metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, + metadata: Dict[str, object] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/honcho/resources/apps/users/collections/documents.py b/src/honcho/resources/apps/users/collections/documents.py index cd6f010..de7a276 100644 --- a/src/honcho/resources/apps/users/collections/documents.py +++ b/src/honcho/resources/apps/users/collections/documents.py @@ -60,7 +60,7 @@ def create( app_id: str, user_id: str, content: str, - metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, + metadata: Dict[str, object] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -375,7 +375,7 @@ async def create( app_id: str, user_id: str, content: str, - metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, + metadata: Dict[str, object] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/honcho/resources/apps/users/sessions/messages.py b/src/honcho/resources/apps/users/sessions/messages.py index 944eff5..88b040b 100644 --- a/src/honcho/resources/apps/users/sessions/messages.py +++ b/src/honcho/resources/apps/users/sessions/messages.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Dict, Iterable, Optional import httpx @@ -21,8 +21,14 @@ ) from .....pagination import SyncPage, AsyncPage from ....._base_client import AsyncPaginator, make_request_options -from .....types.apps.users.sessions import message_list_params, message_create_params, message_update_params +from .....types.apps.users.sessions import ( + message_list_params, + message_batch_params, + message_create_params, + message_update_params, +) from .....types.apps.users.sessions.message import Message +from .....types.apps.users.sessions.message_batch_response import MessageBatchResponse __all__ = ["MessagesResource", "AsyncMessagesResource"] @@ -104,7 +110,7 @@ def update( app_id: str, user_id: str, session_id: str, - metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, + metadata: Dict[str, object], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -202,6 +208,49 @@ def list( method="post", ) + def batch( + self, + session_id: str, + *, + app_id: str, + user_id: str, + messages: Iterable[message_batch_params.Message], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> MessageBatchResponse: + """Bulk create messages for a session while maintaining order. + + Maximum 100 messages + per batch. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if not user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + if not session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return self._post( + f"/v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/batch", + body=maybe_transform({"messages": messages}, message_batch_params.MessageBatchParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessageBatchResponse, + ) + def get( self, message_id: str, @@ -322,7 +371,7 @@ async def update( app_id: str, user_id: str, session_id: str, - metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, + metadata: Dict[str, object], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -420,6 +469,49 @@ def list( method="post", ) + async def batch( + self, + session_id: str, + *, + app_id: str, + user_id: str, + messages: Iterable[message_batch_params.Message], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> MessageBatchResponse: + """Bulk create messages for a session while maintaining order. + + Maximum 100 messages + per batch. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if not user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + if not session_id: + raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") + return await self._post( + f"/v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/batch", + body=await async_maybe_transform({"messages": messages}, message_batch_params.MessageBatchParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MessageBatchResponse, + ) + async def get( self, message_id: str, @@ -476,6 +568,9 @@ def __init__(self, messages: MessagesResource) -> None: self.list = to_raw_response_wrapper( messages.list, ) + self.batch = to_raw_response_wrapper( + messages.batch, + ) self.get = to_raw_response_wrapper( messages.get, ) @@ -494,6 +589,9 @@ def __init__(self, messages: AsyncMessagesResource) -> None: self.list = async_to_raw_response_wrapper( messages.list, ) + self.batch = async_to_raw_response_wrapper( + messages.batch, + ) self.get = async_to_raw_response_wrapper( messages.get, ) @@ -512,6 +610,9 @@ def __init__(self, messages: MessagesResource) -> None: self.list = to_streamed_response_wrapper( messages.list, ) + self.batch = to_streamed_response_wrapper( + messages.batch, + ) self.get = to_streamed_response_wrapper( messages.get, ) @@ -530,6 +631,9 @@ def __init__(self, messages: AsyncMessagesResource) -> None: self.list = async_to_streamed_response_wrapper( messages.list, ) + self.batch = async_to_streamed_response_wrapper( + messages.batch, + ) self.get = async_to_streamed_response_wrapper( messages.get, ) diff --git a/src/honcho/resources/apps/users/sessions/metamessages.py b/src/honcho/resources/apps/users/sessions/metamessages.py index 087d839..f6edab2 100644 --- a/src/honcho/resources/apps/users/sessions/metamessages.py +++ b/src/honcho/resources/apps/users/sessions/metamessages.py @@ -61,7 +61,7 @@ def create( content: str, message_id: str, metamessage_type: str, - metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, + metadata: Dict[str, object] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -304,7 +304,7 @@ async def create( content: str, message_id: str, metamessage_type: str, - metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, + metadata: Dict[str, object] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/honcho/resources/apps/users/sessions/sessions.py b/src/honcho/resources/apps/users/sessions/sessions.py index 4fe1948..0a6fa5c 100644 --- a/src/honcho/resources/apps/users/sessions/sessions.py +++ b/src/honcho/resources/apps/users/sessions/sessions.py @@ -123,7 +123,7 @@ def update( *, app_id: str, user_id: str, - metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, + metadata: Dict[str, object], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -507,7 +507,7 @@ async def update( *, app_id: str, user_id: str, - metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, + metadata: Dict[str, object], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/honcho/types/apps/users/collection_create_params.py b/src/honcho/types/apps/users/collection_create_params.py index 434b8f9..c98672f 100644 --- a/src/honcho/types/apps/users/collection_create_params.py +++ b/src/honcho/types/apps/users/collection_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Dict from typing_extensions import Required, TypedDict __all__ = ["CollectionCreateParams"] @@ -13,4 +13,4 @@ class CollectionCreateParams(TypedDict, total=False): name: Required[str] - metadata: Optional[Dict[str, object]] + metadata: Dict[str, object] diff --git a/src/honcho/types/apps/users/collections/document_create_params.py b/src/honcho/types/apps/users/collections/document_create_params.py index f014a94..5851a39 100644 --- a/src/honcho/types/apps/users/collections/document_create_params.py +++ b/src/honcho/types/apps/users/collections/document_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Dict from typing_extensions import Required, TypedDict __all__ = ["DocumentCreateParams"] @@ -15,4 +15,4 @@ class DocumentCreateParams(TypedDict, total=False): content: Required[str] - metadata: Optional[Dict[str, object]] + metadata: Dict[str, object] diff --git a/src/honcho/types/apps/users/session_update_params.py b/src/honcho/types/apps/users/session_update_params.py index 49da04e..19fbe26 100644 --- a/src/honcho/types/apps/users/session_update_params.py +++ b/src/honcho/types/apps/users/session_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Dict from typing_extensions import Required, TypedDict __all__ = ["SessionUpdateParams"] @@ -13,4 +13,4 @@ class SessionUpdateParams(TypedDict, total=False): user_id: Required[str] - metadata: Optional[Dict[str, object]] + metadata: Required[Dict[str, object]] diff --git a/src/honcho/types/apps/users/sessions/__init__.py b/src/honcho/types/apps/users/sessions/__init__.py index 54bcf9b..58d1a9f 100644 --- a/src/honcho/types/apps/users/sessions/__init__.py +++ b/src/honcho/types/apps/users/sessions/__init__.py @@ -7,8 +7,10 @@ from .page_message import PageMessage as PageMessage from .page_metamessage import PageMetamessage as PageMetamessage from .message_list_params import MessageListParams as MessageListParams +from .message_batch_params import MessageBatchParams as MessageBatchParams from .message_create_params import MessageCreateParams as MessageCreateParams from .message_update_params import MessageUpdateParams as MessageUpdateParams +from .message_batch_response import MessageBatchResponse as MessageBatchResponse from .metamessage_get_params import MetamessageGetParams as MetamessageGetParams from .metamessage_list_params import MetamessageListParams as MetamessageListParams from .metamessage_create_params import MetamessageCreateParams as MetamessageCreateParams diff --git a/src/honcho/types/apps/users/sessions/message_batch_params.py b/src/honcho/types/apps/users/sessions/message_batch_params.py new file mode 100644 index 0000000..af30a67 --- /dev/null +++ b/src/honcho/types/apps/users/sessions/message_batch_params.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Iterable +from typing_extensions import Required, TypedDict + +__all__ = ["MessageBatchParams", "Message"] + + +class MessageBatchParams(TypedDict, total=False): + app_id: Required[str] + + user_id: Required[str] + + messages: Required[Iterable[Message]] + + +class Message(TypedDict, total=False): + content: Required[str] + + is_user: Required[bool] + + metadata: Dict[str, object] diff --git a/src/honcho/types/apps/users/sessions/message_batch_response.py b/src/honcho/types/apps/users/sessions/message_batch_response.py new file mode 100644 index 0000000..e114857 --- /dev/null +++ b/src/honcho/types/apps/users/sessions/message_batch_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import TypeAlias + +from .message import Message + +__all__ = ["MessageBatchResponse"] + +MessageBatchResponse: TypeAlias = List[Message] diff --git a/src/honcho/types/apps/users/sessions/message_update_params.py b/src/honcho/types/apps/users/sessions/message_update_params.py index df422aa..e3409be 100644 --- a/src/honcho/types/apps/users/sessions/message_update_params.py +++ b/src/honcho/types/apps/users/sessions/message_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Dict from typing_extensions import Required, TypedDict __all__ = ["MessageUpdateParams"] @@ -15,4 +15,4 @@ class MessageUpdateParams(TypedDict, total=False): session_id: Required[str] - metadata: Optional[Dict[str, object]] + metadata: Required[Dict[str, object]] diff --git a/src/honcho/types/apps/users/sessions/metamessage_create_params.py b/src/honcho/types/apps/users/sessions/metamessage_create_params.py index 71a60d1..7632849 100644 --- a/src/honcho/types/apps/users/sessions/metamessage_create_params.py +++ b/src/honcho/types/apps/users/sessions/metamessage_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Dict from typing_extensions import Required, TypedDict __all__ = ["MetamessageCreateParams"] @@ -19,4 +19,4 @@ class MetamessageCreateParams(TypedDict, total=False): metamessage_type: Required[str] - metadata: Optional[Dict[str, object]] + metadata: Dict[str, object] diff --git a/tests/api_resources/apps/test_users.py b/tests/api_resources/apps/test_users.py index d8623af..0df68a7 100644 --- a/tests/api_resources/apps/test_users.py +++ b/tests/api_resources/apps/test_users.py @@ -22,7 +22,7 @@ class TestUsers: def test_method_create(self, client: Honcho) -> None: user = client.apps.users.create( app_id="app_id", - name="name", + name="x", ) assert_matches_type(User, user, path=["response"]) @@ -30,7 +30,7 @@ def test_method_create(self, client: Honcho) -> None: def test_method_create_with_all_params(self, client: Honcho) -> None: user = client.apps.users.create( app_id="app_id", - name="name", + name="x", metadata={"foo": "bar"}, ) assert_matches_type(User, user, path=["response"]) @@ -39,7 +39,7 @@ def test_method_create_with_all_params(self, client: Honcho) -> None: def test_raw_response_create(self, client: Honcho) -> None: response = client.apps.users.with_raw_response.create( app_id="app_id", - name="name", + name="x", ) assert response.is_closed is True @@ -51,7 +51,7 @@ def test_raw_response_create(self, client: Honcho) -> None: def test_streaming_response_create(self, client: Honcho) -> None: with client.apps.users.with_streaming_response.create( app_id="app_id", - name="name", + name="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -66,7 +66,7 @@ def test_path_params_create(self, client: Honcho) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): client.apps.users.with_raw_response.create( app_id="", - name="name", + name="x", ) @parametrize @@ -328,7 +328,7 @@ class TestAsyncUsers: async def test_method_create(self, async_client: AsyncHoncho) -> None: user = await async_client.apps.users.create( app_id="app_id", - name="name", + name="x", ) assert_matches_type(User, user, path=["response"]) @@ -336,7 +336,7 @@ async def test_method_create(self, async_client: AsyncHoncho) -> None: async def test_method_create_with_all_params(self, async_client: AsyncHoncho) -> None: user = await async_client.apps.users.create( app_id="app_id", - name="name", + name="x", metadata={"foo": "bar"}, ) assert_matches_type(User, user, path=["response"]) @@ -345,7 +345,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncHoncho) -> async def test_raw_response_create(self, async_client: AsyncHoncho) -> None: response = await async_client.apps.users.with_raw_response.create( app_id="app_id", - name="name", + name="x", ) assert response.is_closed is True @@ -357,7 +357,7 @@ async def test_raw_response_create(self, async_client: AsyncHoncho) -> None: async def test_streaming_response_create(self, async_client: AsyncHoncho) -> None: async with async_client.apps.users.with_streaming_response.create( app_id="app_id", - name="name", + name="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -372,7 +372,7 @@ async def test_path_params_create(self, async_client: AsyncHoncho) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): await async_client.apps.users.with_raw_response.create( app_id="", - name="name", + name="x", ) @parametrize diff --git a/tests/api_resources/apps/users/collections/test_documents.py b/tests/api_resources/apps/users/collections/test_documents.py index a2c4f2f..afddd2d 100644 --- a/tests/api_resources/apps/users/collections/test_documents.py +++ b/tests/api_resources/apps/users/collections/test_documents.py @@ -27,7 +27,7 @@ def test_method_create(self, client: Honcho) -> None: collection_id="collection_id", app_id="app_id", user_id="user_id", - content="content", + content="x", ) assert_matches_type(Document, document, path=["response"]) @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Honcho) -> None: collection_id="collection_id", app_id="app_id", user_id="user_id", - content="content", + content="x", metadata={"foo": "bar"}, ) assert_matches_type(Document, document, path=["response"]) @@ -48,7 +48,7 @@ def test_raw_response_create(self, client: Honcho) -> None: collection_id="collection_id", app_id="app_id", user_id="user_id", - content="content", + content="x", ) assert response.is_closed is True @@ -62,7 +62,7 @@ def test_streaming_response_create(self, client: Honcho) -> None: collection_id="collection_id", app_id="app_id", user_id="user_id", - content="content", + content="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -79,7 +79,7 @@ def test_path_params_create(self, client: Honcho) -> None: collection_id="collection_id", app_id="", user_id="user_id", - content="content", + content="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): @@ -87,7 +87,7 @@ def test_path_params_create(self, client: Honcho) -> None: collection_id="collection_id", app_id="app_id", user_id="", - content="content", + content="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `collection_id` but received ''"): @@ -95,7 +95,7 @@ def test_path_params_create(self, client: Honcho) -> None: collection_id="", app_id="app_id", user_id="user_id", - content="content", + content="x", ) @parametrize @@ -115,7 +115,7 @@ def test_method_update_with_all_params(self, client: Honcho) -> None: app_id="app_id", user_id="user_id", collection_id="collection_id", - content="content", + content="x", metadata={"foo": "bar"}, ) assert_matches_type(Document, document, path=["response"]) @@ -411,7 +411,7 @@ def test_method_query(self, client: Honcho) -> None: collection_id="collection_id", app_id="app_id", user_id="user_id", - query="query", + query="x", ) assert_matches_type(DocumentQueryResponse, document, path=["response"]) @@ -421,9 +421,9 @@ def test_method_query_with_all_params(self, client: Honcho) -> None: collection_id="collection_id", app_id="app_id", user_id="user_id", - query="query", + query="x", filter={"foo": "bar"}, - top_k=0, + top_k=1, ) assert_matches_type(DocumentQueryResponse, document, path=["response"]) @@ -433,7 +433,7 @@ def test_raw_response_query(self, client: Honcho) -> None: collection_id="collection_id", app_id="app_id", user_id="user_id", - query="query", + query="x", ) assert response.is_closed is True @@ -447,7 +447,7 @@ def test_streaming_response_query(self, client: Honcho) -> None: collection_id="collection_id", app_id="app_id", user_id="user_id", - query="query", + query="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -464,7 +464,7 @@ def test_path_params_query(self, client: Honcho) -> None: collection_id="collection_id", app_id="", user_id="user_id", - query="query", + query="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): @@ -472,7 +472,7 @@ def test_path_params_query(self, client: Honcho) -> None: collection_id="collection_id", app_id="app_id", user_id="", - query="query", + query="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `collection_id` but received ''"): @@ -480,7 +480,7 @@ def test_path_params_query(self, client: Honcho) -> None: collection_id="", app_id="app_id", user_id="user_id", - query="query", + query="x", ) @@ -493,7 +493,7 @@ async def test_method_create(self, async_client: AsyncHoncho) -> None: collection_id="collection_id", app_id="app_id", user_id="user_id", - content="content", + content="x", ) assert_matches_type(Document, document, path=["response"]) @@ -503,7 +503,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncHoncho) -> collection_id="collection_id", app_id="app_id", user_id="user_id", - content="content", + content="x", metadata={"foo": "bar"}, ) assert_matches_type(Document, document, path=["response"]) @@ -514,7 +514,7 @@ async def test_raw_response_create(self, async_client: AsyncHoncho) -> None: collection_id="collection_id", app_id="app_id", user_id="user_id", - content="content", + content="x", ) assert response.is_closed is True @@ -528,7 +528,7 @@ async def test_streaming_response_create(self, async_client: AsyncHoncho) -> Non collection_id="collection_id", app_id="app_id", user_id="user_id", - content="content", + content="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -545,7 +545,7 @@ async def test_path_params_create(self, async_client: AsyncHoncho) -> None: collection_id="collection_id", app_id="", user_id="user_id", - content="content", + content="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): @@ -553,7 +553,7 @@ async def test_path_params_create(self, async_client: AsyncHoncho) -> None: collection_id="collection_id", app_id="app_id", user_id="", - content="content", + content="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `collection_id` but received ''"): @@ -561,7 +561,7 @@ async def test_path_params_create(self, async_client: AsyncHoncho) -> None: collection_id="", app_id="app_id", user_id="user_id", - content="content", + content="x", ) @parametrize @@ -581,7 +581,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncHoncho) -> app_id="app_id", user_id="user_id", collection_id="collection_id", - content="content", + content="x", metadata={"foo": "bar"}, ) assert_matches_type(Document, document, path=["response"]) @@ -877,7 +877,7 @@ async def test_method_query(self, async_client: AsyncHoncho) -> None: collection_id="collection_id", app_id="app_id", user_id="user_id", - query="query", + query="x", ) assert_matches_type(DocumentQueryResponse, document, path=["response"]) @@ -887,9 +887,9 @@ async def test_method_query_with_all_params(self, async_client: AsyncHoncho) -> collection_id="collection_id", app_id="app_id", user_id="user_id", - query="query", + query="x", filter={"foo": "bar"}, - top_k=0, + top_k=1, ) assert_matches_type(DocumentQueryResponse, document, path=["response"]) @@ -899,7 +899,7 @@ async def test_raw_response_query(self, async_client: AsyncHoncho) -> None: collection_id="collection_id", app_id="app_id", user_id="user_id", - query="query", + query="x", ) assert response.is_closed is True @@ -913,7 +913,7 @@ async def test_streaming_response_query(self, async_client: AsyncHoncho) -> None collection_id="collection_id", app_id="app_id", user_id="user_id", - query="query", + query="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -930,7 +930,7 @@ async def test_path_params_query(self, async_client: AsyncHoncho) -> None: collection_id="collection_id", app_id="", user_id="user_id", - query="query", + query="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): @@ -938,7 +938,7 @@ async def test_path_params_query(self, async_client: AsyncHoncho) -> None: collection_id="collection_id", app_id="app_id", user_id="", - query="query", + query="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `collection_id` but received ''"): @@ -946,5 +946,5 @@ async def test_path_params_query(self, async_client: AsyncHoncho) -> None: collection_id="", app_id="app_id", user_id="user_id", - query="query", + query="x", ) diff --git a/tests/api_resources/apps/users/sessions/test_messages.py b/tests/api_resources/apps/users/sessions/test_messages.py index f1288d9..211fa2c 100644 --- a/tests/api_resources/apps/users/sessions/test_messages.py +++ b/tests/api_resources/apps/users/sessions/test_messages.py @@ -10,7 +10,10 @@ from honcho import Honcho, AsyncHoncho from tests.utils import assert_matches_type from honcho.pagination import SyncPage, AsyncPage -from honcho.types.apps.users.sessions import Message +from honcho.types.apps.users.sessions import ( + Message, + MessageBatchResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -104,16 +107,6 @@ def test_path_params_create(self, client: Honcho) -> None: @parametrize def test_method_update(self, client: Honcho) -> None: - message = client.apps.users.sessions.messages.update( - message_id="message_id", - app_id="app_id", - user_id="user_id", - session_id="session_id", - ) - assert_matches_type(Message, message, path=["response"]) - - @parametrize - def test_method_update_with_all_params(self, client: Honcho) -> None: message = client.apps.users.sessions.messages.update( message_id="message_id", app_id="app_id", @@ -130,6 +123,7 @@ def test_raw_response_update(self, client: Honcho) -> None: app_id="app_id", user_id="user_id", session_id="session_id", + metadata={"foo": "bar"}, ) assert response.is_closed is True @@ -144,6 +138,7 @@ def test_streaming_response_update(self, client: Honcho) -> None: app_id="app_id", user_id="user_id", session_id="session_id", + metadata={"foo": "bar"}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -161,6 +156,7 @@ def test_path_params_update(self, client: Honcho) -> None: app_id="", user_id="user_id", session_id="session_id", + metadata={"foo": "bar"}, ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): @@ -169,6 +165,7 @@ def test_path_params_update(self, client: Honcho) -> None: app_id="app_id", user_id="", session_id="session_id", + metadata={"foo": "bar"}, ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): @@ -177,6 +174,7 @@ def test_path_params_update(self, client: Honcho) -> None: app_id="app_id", user_id="user_id", session_id="", + metadata={"foo": "bar"}, ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): @@ -185,6 +183,7 @@ def test_path_params_update(self, client: Honcho) -> None: app_id="app_id", user_id="user_id", session_id="session_id", + metadata={"foo": "bar"}, ) @parametrize @@ -260,6 +259,102 @@ def test_path_params_list(self, client: Honcho) -> None: user_id="user_id", ) + @parametrize + def test_method_batch(self, client: Honcho) -> None: + message = client.apps.users.sessions.messages.batch( + session_id="session_id", + app_id="app_id", + user_id="user_id", + messages=[ + { + "content": "content", + "is_user": True, + } + ], + ) + assert_matches_type(MessageBatchResponse, message, path=["response"]) + + @parametrize + def test_raw_response_batch(self, client: Honcho) -> None: + response = client.apps.users.sessions.messages.with_raw_response.batch( + session_id="session_id", + app_id="app_id", + user_id="user_id", + messages=[ + { + "content": "content", + "is_user": True, + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + message = response.parse() + assert_matches_type(MessageBatchResponse, message, path=["response"]) + + @parametrize + def test_streaming_response_batch(self, client: Honcho) -> None: + with client.apps.users.sessions.messages.with_streaming_response.batch( + session_id="session_id", + app_id="app_id", + user_id="user_id", + messages=[ + { + "content": "content", + "is_user": True, + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + message = response.parse() + assert_matches_type(MessageBatchResponse, message, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_batch(self, client: Honcho) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + client.apps.users.sessions.messages.with_raw_response.batch( + session_id="session_id", + app_id="", + user_id="user_id", + messages=[ + { + "content": "content", + "is_user": True, + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + client.apps.users.sessions.messages.with_raw_response.batch( + session_id="session_id", + app_id="app_id", + user_id="", + messages=[ + { + "content": "content", + "is_user": True, + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + client.apps.users.sessions.messages.with_raw_response.batch( + session_id="", + app_id="app_id", + user_id="user_id", + messages=[ + { + "content": "content", + "is_user": True, + } + ], + ) + @parametrize def test_method_get(self, client: Honcho) -> None: message = client.apps.users.sessions.messages.get( @@ -424,16 +519,6 @@ async def test_path_params_create(self, async_client: AsyncHoncho) -> None: @parametrize async def test_method_update(self, async_client: AsyncHoncho) -> None: - message = await async_client.apps.users.sessions.messages.update( - message_id="message_id", - app_id="app_id", - user_id="user_id", - session_id="session_id", - ) - assert_matches_type(Message, message, path=["response"]) - - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncHoncho) -> None: message = await async_client.apps.users.sessions.messages.update( message_id="message_id", app_id="app_id", @@ -450,6 +535,7 @@ async def test_raw_response_update(self, async_client: AsyncHoncho) -> None: app_id="app_id", user_id="user_id", session_id="session_id", + metadata={"foo": "bar"}, ) assert response.is_closed is True @@ -464,6 +550,7 @@ async def test_streaming_response_update(self, async_client: AsyncHoncho) -> Non app_id="app_id", user_id="user_id", session_id="session_id", + metadata={"foo": "bar"}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -481,6 +568,7 @@ async def test_path_params_update(self, async_client: AsyncHoncho) -> None: app_id="", user_id="user_id", session_id="session_id", + metadata={"foo": "bar"}, ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): @@ -489,6 +577,7 @@ async def test_path_params_update(self, async_client: AsyncHoncho) -> None: app_id="app_id", user_id="", session_id="session_id", + metadata={"foo": "bar"}, ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): @@ -497,6 +586,7 @@ async def test_path_params_update(self, async_client: AsyncHoncho) -> None: app_id="app_id", user_id="user_id", session_id="", + metadata={"foo": "bar"}, ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): @@ -505,6 +595,7 @@ async def test_path_params_update(self, async_client: AsyncHoncho) -> None: app_id="app_id", user_id="user_id", session_id="session_id", + metadata={"foo": "bar"}, ) @parametrize @@ -580,6 +671,102 @@ async def test_path_params_list(self, async_client: AsyncHoncho) -> None: user_id="user_id", ) + @parametrize + async def test_method_batch(self, async_client: AsyncHoncho) -> None: + message = await async_client.apps.users.sessions.messages.batch( + session_id="session_id", + app_id="app_id", + user_id="user_id", + messages=[ + { + "content": "content", + "is_user": True, + } + ], + ) + assert_matches_type(MessageBatchResponse, message, path=["response"]) + + @parametrize + async def test_raw_response_batch(self, async_client: AsyncHoncho) -> None: + response = await async_client.apps.users.sessions.messages.with_raw_response.batch( + session_id="session_id", + app_id="app_id", + user_id="user_id", + messages=[ + { + "content": "content", + "is_user": True, + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + message = await response.parse() + assert_matches_type(MessageBatchResponse, message, path=["response"]) + + @parametrize + async def test_streaming_response_batch(self, async_client: AsyncHoncho) -> None: + async with async_client.apps.users.sessions.messages.with_streaming_response.batch( + session_id="session_id", + app_id="app_id", + user_id="user_id", + messages=[ + { + "content": "content", + "is_user": True, + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + message = await response.parse() + assert_matches_type(MessageBatchResponse, message, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_batch(self, async_client: AsyncHoncho) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + await async_client.apps.users.sessions.messages.with_raw_response.batch( + session_id="session_id", + app_id="", + user_id="user_id", + messages=[ + { + "content": "content", + "is_user": True, + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + await async_client.apps.users.sessions.messages.with_raw_response.batch( + session_id="session_id", + app_id="app_id", + user_id="", + messages=[ + { + "content": "content", + "is_user": True, + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): + await async_client.apps.users.sessions.messages.with_raw_response.batch( + session_id="", + app_id="app_id", + user_id="user_id", + messages=[ + { + "content": "content", + "is_user": True, + } + ], + ) + @parametrize async def test_method_get(self, async_client: AsyncHoncho) -> None: message = await async_client.apps.users.sessions.messages.get( diff --git a/tests/api_resources/apps/users/sessions/test_metamessages.py b/tests/api_resources/apps/users/sessions/test_metamessages.py index 4fcd638..3a89acf 100644 --- a/tests/api_resources/apps/users/sessions/test_metamessages.py +++ b/tests/api_resources/apps/users/sessions/test_metamessages.py @@ -28,7 +28,7 @@ def test_method_create(self, client: Honcho) -> None: user_id="user_id", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", ) assert_matches_type(Metamessage, metamessage, path=["response"]) @@ -40,7 +40,7 @@ def test_method_create_with_all_params(self, client: Honcho) -> None: user_id="user_id", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", metadata={"foo": "bar"}, ) assert_matches_type(Metamessage, metamessage, path=["response"]) @@ -53,7 +53,7 @@ def test_raw_response_create(self, client: Honcho) -> None: user_id="user_id", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", ) assert response.is_closed is True @@ -69,7 +69,7 @@ def test_streaming_response_create(self, client: Honcho) -> None: user_id="user_id", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -88,7 +88,7 @@ def test_path_params_create(self, client: Honcho) -> None: user_id="user_id", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): @@ -98,7 +98,7 @@ def test_path_params_create(self, client: Honcho) -> None: user_id="", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): @@ -108,7 +108,7 @@ def test_path_params_create(self, client: Honcho) -> None: user_id="user_id", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", ) @parametrize @@ -373,7 +373,7 @@ async def test_method_create(self, async_client: AsyncHoncho) -> None: user_id="user_id", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", ) assert_matches_type(Metamessage, metamessage, path=["response"]) @@ -385,7 +385,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncHoncho) -> user_id="user_id", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", metadata={"foo": "bar"}, ) assert_matches_type(Metamessage, metamessage, path=["response"]) @@ -398,7 +398,7 @@ async def test_raw_response_create(self, async_client: AsyncHoncho) -> None: user_id="user_id", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", ) assert response.is_closed is True @@ -414,7 +414,7 @@ async def test_streaming_response_create(self, async_client: AsyncHoncho) -> Non user_id="user_id", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -433,7 +433,7 @@ async def test_path_params_create(self, async_client: AsyncHoncho) -> None: user_id="user_id", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): @@ -443,7 +443,7 @@ async def test_path_params_create(self, async_client: AsyncHoncho) -> None: user_id="", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): @@ -453,7 +453,7 @@ async def test_path_params_create(self, async_client: AsyncHoncho) -> None: user_id="user_id", content="content", message_id="message_id", - metamessage_type="metamessage_type", + metamessage_type="x", ) @parametrize diff --git a/tests/api_resources/apps/users/test_collections.py b/tests/api_resources/apps/users/test_collections.py index 7295226..b9dc989 100644 --- a/tests/api_resources/apps/users/test_collections.py +++ b/tests/api_resources/apps/users/test_collections.py @@ -25,7 +25,7 @@ def test_method_create(self, client: Honcho) -> None: collection = client.apps.users.collections.create( user_id="user_id", app_id="app_id", - name="name", + name="x", ) assert_matches_type(Collection, collection, path=["response"]) @@ -34,7 +34,7 @@ def test_method_create_with_all_params(self, client: Honcho) -> None: collection = client.apps.users.collections.create( user_id="user_id", app_id="app_id", - name="name", + name="x", metadata={"foo": "bar"}, ) assert_matches_type(Collection, collection, path=["response"]) @@ -44,7 +44,7 @@ def test_raw_response_create(self, client: Honcho) -> None: response = client.apps.users.collections.with_raw_response.create( user_id="user_id", app_id="app_id", - name="name", + name="x", ) assert response.is_closed is True @@ -57,7 +57,7 @@ def test_streaming_response_create(self, client: Honcho) -> None: with client.apps.users.collections.with_streaming_response.create( user_id="user_id", app_id="app_id", - name="name", + name="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -73,14 +73,14 @@ def test_path_params_create(self, client: Honcho) -> None: client.apps.users.collections.with_raw_response.create( user_id="user_id", app_id="", - name="name", + name="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): client.apps.users.collections.with_raw_response.create( user_id="", app_id="app_id", - name="name", + name="x", ) @parametrize @@ -403,7 +403,7 @@ async def test_method_create(self, async_client: AsyncHoncho) -> None: collection = await async_client.apps.users.collections.create( user_id="user_id", app_id="app_id", - name="name", + name="x", ) assert_matches_type(Collection, collection, path=["response"]) @@ -412,7 +412,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncHoncho) -> collection = await async_client.apps.users.collections.create( user_id="user_id", app_id="app_id", - name="name", + name="x", metadata={"foo": "bar"}, ) assert_matches_type(Collection, collection, path=["response"]) @@ -422,7 +422,7 @@ async def test_raw_response_create(self, async_client: AsyncHoncho) -> None: response = await async_client.apps.users.collections.with_raw_response.create( user_id="user_id", app_id="app_id", - name="name", + name="x", ) assert response.is_closed is True @@ -435,7 +435,7 @@ async def test_streaming_response_create(self, async_client: AsyncHoncho) -> Non async with async_client.apps.users.collections.with_streaming_response.create( user_id="user_id", app_id="app_id", - name="name", + name="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -451,14 +451,14 @@ async def test_path_params_create(self, async_client: AsyncHoncho) -> None: await async_client.apps.users.collections.with_raw_response.create( user_id="user_id", app_id="", - name="name", + name="x", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): await async_client.apps.users.collections.with_raw_response.create( user_id="", app_id="app_id", - name="name", + name="x", ) @parametrize diff --git a/tests/api_resources/apps/users/test_sessions.py b/tests/api_resources/apps/users/test_sessions.py index 1218405..46cdcfe 100644 --- a/tests/api_resources/apps/users/test_sessions.py +++ b/tests/api_resources/apps/users/test_sessions.py @@ -80,15 +80,6 @@ def test_path_params_create(self, client: Honcho) -> None: @parametrize def test_method_update(self, client: Honcho) -> None: - session = client.apps.users.sessions.update( - session_id="session_id", - app_id="app_id", - user_id="user_id", - ) - assert_matches_type(Session, session, path=["response"]) - - @parametrize - def test_method_update_with_all_params(self, client: Honcho) -> None: session = client.apps.users.sessions.update( session_id="session_id", app_id="app_id", @@ -103,6 +94,7 @@ def test_raw_response_update(self, client: Honcho) -> None: session_id="session_id", app_id="app_id", user_id="user_id", + metadata={"foo": "bar"}, ) assert response.is_closed is True @@ -116,6 +108,7 @@ def test_streaming_response_update(self, client: Honcho) -> None: session_id="session_id", app_id="app_id", user_id="user_id", + metadata={"foo": "bar"}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -132,6 +125,7 @@ def test_path_params_update(self, client: Honcho) -> None: session_id="session_id", app_id="", user_id="user_id", + metadata={"foo": "bar"}, ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): @@ -139,6 +133,7 @@ def test_path_params_update(self, client: Honcho) -> None: session_id="session_id", app_id="app_id", user_id="", + metadata={"foo": "bar"}, ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): @@ -146,6 +141,7 @@ def test_path_params_update(self, client: Honcho) -> None: session_id="", app_id="app_id", user_id="user_id", + metadata={"foo": "bar"}, ) @parametrize @@ -595,15 +591,6 @@ async def test_path_params_create(self, async_client: AsyncHoncho) -> None: @parametrize async def test_method_update(self, async_client: AsyncHoncho) -> None: - session = await async_client.apps.users.sessions.update( - session_id="session_id", - app_id="app_id", - user_id="user_id", - ) - assert_matches_type(Session, session, path=["response"]) - - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncHoncho) -> None: session = await async_client.apps.users.sessions.update( session_id="session_id", app_id="app_id", @@ -618,6 +605,7 @@ async def test_raw_response_update(self, async_client: AsyncHoncho) -> None: session_id="session_id", app_id="app_id", user_id="user_id", + metadata={"foo": "bar"}, ) assert response.is_closed is True @@ -631,6 +619,7 @@ async def test_streaming_response_update(self, async_client: AsyncHoncho) -> Non session_id="session_id", app_id="app_id", user_id="user_id", + metadata={"foo": "bar"}, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -647,6 +636,7 @@ async def test_path_params_update(self, async_client: AsyncHoncho) -> None: session_id="session_id", app_id="", user_id="user_id", + metadata={"foo": "bar"}, ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): @@ -654,6 +644,7 @@ async def test_path_params_update(self, async_client: AsyncHoncho) -> None: session_id="session_id", app_id="app_id", user_id="", + metadata={"foo": "bar"}, ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"): @@ -661,6 +652,7 @@ async def test_path_params_update(self, async_client: AsyncHoncho) -> None: session_id="", app_id="app_id", user_id="user_id", + metadata={"foo": "bar"}, ) @parametrize diff --git a/tests/api_resources/test_apps.py b/tests/api_resources/test_apps.py index 07cc27e..91e8c2e 100644 --- a/tests/api_resources/test_apps.py +++ b/tests/api_resources/test_apps.py @@ -20,14 +20,14 @@ class TestApps: @parametrize def test_method_create(self, client: Honcho) -> None: app = client.apps.create( - name="name", + name="x", ) assert_matches_type(App, app, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Honcho) -> None: app = client.apps.create( - name="name", + name="x", metadata={"foo": "bar"}, ) assert_matches_type(App, app, path=["response"]) @@ -35,7 +35,7 @@ def test_method_create_with_all_params(self, client: Honcho) -> None: @parametrize def test_raw_response_create(self, client: Honcho) -> None: response = client.apps.with_raw_response.create( - name="name", + name="x", ) assert response.is_closed is True @@ -46,7 +46,7 @@ def test_raw_response_create(self, client: Honcho) -> None: @parametrize def test_streaming_response_create(self, client: Honcho) -> None: with client.apps.with_streaming_response.create( - name="name", + name="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -224,14 +224,14 @@ class TestAsyncApps: @parametrize async def test_method_create(self, async_client: AsyncHoncho) -> None: app = await async_client.apps.create( - name="name", + name="x", ) assert_matches_type(App, app, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncHoncho) -> None: app = await async_client.apps.create( - name="name", + name="x", metadata={"foo": "bar"}, ) assert_matches_type(App, app, path=["response"]) @@ -239,7 +239,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncHoncho) -> @parametrize async def test_raw_response_create(self, async_client: AsyncHoncho) -> None: response = await async_client.apps.with_raw_response.create( - name="name", + name="x", ) assert response.is_closed is True @@ -250,7 +250,7 @@ async def test_raw_response_create(self, async_client: AsyncHoncho) -> None: @parametrize async def test_streaming_response_create(self, async_client: AsyncHoncho) -> None: async with async_client.apps.with_streaming_response.create( - name="name", + name="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/test_client.py b/tests/test_client.py index 080317c..37451fe 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -717,7 +717,7 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> No with pytest.raises(APITimeoutError): self.client.post( "/v1/apps", - body=cast(object, dict(name="name")), + body=cast(object, dict(name="x")), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, ) @@ -732,7 +732,7 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> Non with pytest.raises(APIStatusError): self.client.post( "/v1/apps", - body=cast(object, dict(name="name")), + body=cast(object, dict(name="x")), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, ) @@ -765,7 +765,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: respx_mock.post("/v1/apps").mock(side_effect=retry_handler) - response = client.apps.with_raw_response.create(name="name") + response = client.apps.with_raw_response.create(name="x") assert response.retries_taken == failures_before_success assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success @@ -789,7 +789,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: respx_mock.post("/v1/apps").mock(side_effect=retry_handler) - response = client.apps.with_raw_response.create(name="name", extra_headers={"x-stainless-retry-count": Omit()}) + response = client.apps.with_raw_response.create(name="x", extra_headers={"x-stainless-retry-count": Omit()}) assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0 @@ -812,7 +812,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: respx_mock.post("/v1/apps").mock(side_effect=retry_handler) - response = client.apps.with_raw_response.create(name="name", extra_headers={"x-stainless-retry-count": "42"}) + response = client.apps.with_raw_response.create(name="x", extra_headers={"x-stainless-retry-count": "42"}) assert response.http_request.headers.get("x-stainless-retry-count") == "42" @@ -1501,7 +1501,7 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) with pytest.raises(APITimeoutError): await self.client.post( "/v1/apps", - body=cast(object, dict(name="name")), + body=cast(object, dict(name="x")), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, ) @@ -1516,7 +1516,7 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) with pytest.raises(APIStatusError): await self.client.post( "/v1/apps", - body=cast(object, dict(name="name")), + body=cast(object, dict(name="x")), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, ) @@ -1550,7 +1550,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: respx_mock.post("/v1/apps").mock(side_effect=retry_handler) - response = await client.apps.with_raw_response.create(name="name") + response = await client.apps.with_raw_response.create(name="x") assert response.retries_taken == failures_before_success assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success @@ -1576,7 +1576,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: respx_mock.post("/v1/apps").mock(side_effect=retry_handler) response = await client.apps.with_raw_response.create( - name="name", extra_headers={"x-stainless-retry-count": Omit()} + name="x", extra_headers={"x-stainless-retry-count": Omit()} ) assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0 @@ -1601,9 +1601,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: respx_mock.post("/v1/apps").mock(side_effect=retry_handler) - response = await client.apps.with_raw_response.create( - name="name", extra_headers={"x-stainless-retry-count": "42"} - ) + response = await client.apps.with_raw_response.create(name="x", extra_headers={"x-stainless-retry-count": "42"}) assert response.http_request.headers.get("x-stainless-retry-count") == "42"