Skip to content

Commit f31aeaf

Browse files
chore(internal): update client tests (#50)
1 parent 2c1476c commit f31aeaf

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

tests/test_client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
from hyperspell import Hyperspell, AsyncHyperspell, APIResponseValidationError
2525
from hyperspell._types import Omit
26+
from hyperspell._utils import maybe_transform
2627
from hyperspell._models import BaseModel, FinalRequestOptions
2728
from hyperspell._constants import RAW_RESPONSE_HEADER
2829
from hyperspell._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError
@@ -32,6 +33,7 @@
3233
BaseClient,
3334
make_request_options,
3435
)
36+
from hyperspell.types.document_add_params import DocumentAddParams
3537

3638
from .utils import update_env
3739

@@ -734,7 +736,7 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> No
734736
with pytest.raises(APITimeoutError):
735737
self.client.post(
736738
"/documents/add",
737-
body=cast(object, dict(collection="collection", text="text")),
739+
body=cast(object, maybe_transform(dict(collection="collection", text="text"), DocumentAddParams)),
738740
cast_to=httpx.Response,
739741
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
740742
)
@@ -749,7 +751,7 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> Non
749751
with pytest.raises(APIStatusError):
750752
self.client.post(
751753
"/documents/add",
752-
body=cast(object, dict(collection="collection", text="text")),
754+
body=cast(object, maybe_transform(dict(collection="collection", text="text"), DocumentAddParams)),
753755
cast_to=httpx.Response,
754756
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
755757
)
@@ -1523,7 +1525,7 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter)
15231525
with pytest.raises(APITimeoutError):
15241526
await self.client.post(
15251527
"/documents/add",
1526-
body=cast(object, dict(collection="collection", text="text")),
1528+
body=cast(object, maybe_transform(dict(collection="collection", text="text"), DocumentAddParams)),
15271529
cast_to=httpx.Response,
15281530
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
15291531
)
@@ -1538,7 +1540,7 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter)
15381540
with pytest.raises(APIStatusError):
15391541
await self.client.post(
15401542
"/documents/add",
1541-
body=cast(object, dict(collection="collection", text="text")),
1543+
body=cast(object, maybe_transform(dict(collection="collection", text="text"), DocumentAddParams)),
15421544
cast_to=httpx.Response,
15431545
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
15441546
)

0 commit comments

Comments
 (0)