Skip to content

Commit 9297d25

Browse files
chore(internal): update client tests (#68)
1 parent 5697955 commit 9297d25

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

tests/test_client.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323

2424
from codex import Codex, AsyncCodex, APIResponseValidationError
2525
from codex._types import Omit
26+
from codex._utils import maybe_transform
2627
from codex._models import BaseModel, FinalRequestOptions
2728
from codex._constants import RAW_RESPONSE_HEADER
2829
from codex._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError
2930
from codex._base_client import DEFAULT_TIMEOUT, HTTPX_DEFAULT_TIMEOUT, BaseClient, make_request_options
31+
from codex.types.project_create_params import ProjectCreateParams
3032

3133
from .utils import update_env
3234

@@ -680,7 +682,13 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> No
680682
with pytest.raises(APITimeoutError):
681683
self.client.post(
682684
"/api/projects/",
683-
body=cast(object, dict(config={}, name="name", organization_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")),
685+
body=cast(
686+
object,
687+
maybe_transform(
688+
dict(config={}, name="name", organization_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
689+
ProjectCreateParams,
690+
),
691+
),
684692
cast_to=httpx.Response,
685693
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
686694
)
@@ -695,7 +703,13 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> Non
695703
with pytest.raises(APIStatusError):
696704
self.client.post(
697705
"/api/projects/",
698-
body=cast(object, dict(config={}, name="name", organization_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")),
706+
body=cast(
707+
object,
708+
maybe_transform(
709+
dict(config={}, name="name", organization_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
710+
ProjectCreateParams,
711+
),
712+
),
699713
cast_to=httpx.Response,
700714
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
701715
)
@@ -1425,7 +1439,13 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter)
14251439
with pytest.raises(APITimeoutError):
14261440
await self.client.post(
14271441
"/api/projects/",
1428-
body=cast(object, dict(config={}, name="name", organization_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")),
1442+
body=cast(
1443+
object,
1444+
maybe_transform(
1445+
dict(config={}, name="name", organization_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
1446+
ProjectCreateParams,
1447+
),
1448+
),
14291449
cast_to=httpx.Response,
14301450
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
14311451
)
@@ -1440,7 +1460,13 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter)
14401460
with pytest.raises(APIStatusError):
14411461
await self.client.post(
14421462
"/api/projects/",
1443-
body=cast(object, dict(config={}, name="name", organization_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")),
1463+
body=cast(
1464+
object,
1465+
maybe_transform(
1466+
dict(config={}, name="name", organization_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
1467+
ProjectCreateParams,
1468+
),
1469+
),
14441470
cast_to=httpx.Response,
14451471
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
14461472
)

0 commit comments

Comments
 (0)