Skip to content

Commit d401b51

Browse files
committed
test: updated tests for non standard http status codes change
1 parent ae2797f commit d401b51

File tree

65 files changed

+388
-250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+388
-250
lines changed

end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ def to_tuple(self) -> FileTypes:
3939

4040

4141
T = TypeVar("T")
42+
S = TypeVar("S", bound=HTTPStatus | int)
4243

4344

4445
@define
45-
class Response(Generic[T]):
46+
class Response(Generic[T, S]):
4647
"""A response from an endpoint"""
4748

48-
status_code: HTTPStatus
49+
status_code: S
4950
content: bytes
5051
headers: MutableMapping[str, str]
5152
parsed: T | None

end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from http import HTTPStatus
1+
import http
22
from typing import Any
33

44
import httpx
@@ -8,6 +8,8 @@
88
from ...models.json_like_body import JsonLikeBody
99
from ...types import UNSET, Response, Unset
1010

11+
HTTPStatus = http.HTTPStatus
12+
1113

1214
def _get_kwargs(
1315
*,
@@ -39,7 +41,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res
3941
return None
4042

4143

42-
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]:
44+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]:
4345
return Response(
4446
status_code=HTTPStatus(response.status_code),
4547
content=response.content,
@@ -52,7 +54,7 @@ def sync_detailed(
5254
*,
5355
client: AuthenticatedClient | Client,
5456
body: JsonLikeBody | Unset = UNSET,
55-
) -> Response[Any]:
57+
) -> Response[Any, HTTPStatus]:
5658
"""A content type that works like json but isn't application/json
5759
5860
Args:
@@ -81,7 +83,7 @@ async def asyncio_detailed(
8183
*,
8284
client: AuthenticatedClient | Client,
8385
body: JsonLikeBody | Unset = UNSET,
84-
) -> Response[Any]:
86+
) -> Response[Any, HTTPStatus]:
8587
"""A content type that works like json but isn't application/json
8688
8789
Args:

end_to_end_tests/golden-record/my_test_api_client/api/bodies/optional_body.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from http import HTTPStatus
1+
import http
22
from typing import Any
33

44
import httpx
@@ -8,6 +8,8 @@
88
from ...models.optional_body_body import OptionalBodyBody
99
from ...types import UNSET, Response, Unset
1010

11+
HTTPStatus = http.HTTPStatus
12+
1113

1214
def _get_kwargs(
1315
*,
@@ -39,7 +41,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res
3941
return None
4042

4143

42-
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]:
44+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]:
4345
return Response(
4446
status_code=HTTPStatus(response.status_code),
4547
content=response.content,
@@ -52,7 +54,7 @@ def sync_detailed(
5254
*,
5355
client: AuthenticatedClient | Client,
5456
body: OptionalBodyBody | Unset = UNSET,
55-
) -> Response[Any]:
57+
) -> Response[Any, HTTPStatus]:
5658
"""Test optional request body
5759
5860
Args:
@@ -81,7 +83,7 @@ async def asyncio_detailed(
8183
*,
8284
client: AuthenticatedClient | Client,
8385
body: OptionalBodyBody | Unset = UNSET,
84-
) -> Response[Any]:
86+
) -> Response[Any, HTTPStatus]:
8587
"""Test optional request body
8688
8789
Args:

end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from http import HTTPStatus
1+
import http
22
from typing import Any
33

44
import httpx
@@ -10,6 +10,8 @@
1010
from ...models.post_bodies_multiple_json_body import PostBodiesMultipleJsonBody
1111
from ...types import UNSET, File, Response, Unset
1212

13+
HTTPStatus = http.HTTPStatus
14+
1315

1416
def _get_kwargs(
1517
*,
@@ -57,7 +59,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res
5759
return None
5860

5961

60-
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]:
62+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]:
6163
return Response(
6264
status_code=HTTPStatus(response.status_code),
6365
content=response.content,
@@ -70,7 +72,7 @@ def sync_detailed(
7072
*,
7173
client: AuthenticatedClient | Client,
7274
body: PostBodiesMultipleJsonBody | File | PostBodiesMultipleDataBody | PostBodiesMultipleFilesBody | Unset = UNSET,
73-
) -> Response[Any]:
75+
) -> Response[Any, HTTPStatus]:
7476
"""Test multiple bodies
7577
7678
Args:
@@ -102,7 +104,7 @@ async def asyncio_detailed(
102104
*,
103105
client: AuthenticatedClient | Client,
104106
body: PostBodiesMultipleJsonBody | File | PostBodiesMultipleDataBody | PostBodiesMultipleFilesBody | Unset = UNSET,
105-
) -> Response[Any]:
107+
) -> Response[Any, HTTPStatus]:
106108
"""Test multiple bodies
107109
108110
Args:

end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from http import HTTPStatus
1+
import http
22
from typing import Any
33

44
import httpx
@@ -8,6 +8,8 @@
88
from ...models.a_model import AModel
99
from ...types import UNSET, Response, Unset
1010

11+
HTTPStatus = http.HTTPStatus
12+
1113

1214
def _get_kwargs(
1315
*,
@@ -39,7 +41,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res
3941
return None
4042

4143

42-
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]:
44+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]:
4345
return Response(
4446
status_code=HTTPStatus(response.status_code),
4547
content=response.content,
@@ -52,7 +54,7 @@ def sync_detailed(
5254
*,
5355
client: AuthenticatedClient | Client,
5456
body: AModel | Unset = UNSET,
55-
) -> Response[Any]:
57+
) -> Response[Any, HTTPStatus]:
5658
"""Test request body defined via ref
5759
5860
Args:
@@ -81,7 +83,7 @@ async def asyncio_detailed(
8183
*,
8284
client: AuthenticatedClient | Client,
8385
body: AModel | Unset = UNSET,
84-
) -> Response[Any]:
86+
) -> Response[Any, HTTPStatus]:
8587
"""Test request body defined via ref
8688
8789
Args:

end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from http import HTTPStatus
1+
import http
22
from typing import Any, cast
33

44
import httpx
@@ -7,6 +7,8 @@
77
from ...client import AuthenticatedClient, Client
88
from ...types import UNSET, Response, Unset
99

10+
HTTPStatus = http.HTTPStatus
11+
1012

1113
def _get_kwargs(
1214
*,
@@ -39,7 +41,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res
3941
return None
4042

4143

42-
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[str]:
44+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[str, HTTPStatus]:
4345
return Response(
4446
status_code=HTTPStatus(response.status_code),
4547
content=response.content,
@@ -52,7 +54,7 @@ def sync_detailed(
5254
*,
5355
client: AuthenticatedClient | Client,
5456
body: str | Unset = UNSET,
55-
) -> Response[str]:
57+
) -> Response[str, HTTPStatus]:
5658
"""Content Type Override
5759
5860
Args:
@@ -105,7 +107,7 @@ async def asyncio_detailed(
105107
*,
106108
client: AuthenticatedClient | Client,
107109
body: str | Unset = UNSET,
108-
) -> Response[str]:
110+
) -> Response[str, HTTPStatus]:
109111
"""Content Type Override
110112
111113
Args:

end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from http import HTTPStatus
1+
import http
22
from typing import Any
33

44
import httpx
@@ -7,6 +7,8 @@
77
from ...client import AuthenticatedClient, Client
88
from ...types import UNSET, Response, Unset
99

10+
HTTPStatus = http.HTTPStatus
11+
1012

1113
def _get_kwargs(
1214
*,
@@ -37,7 +39,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res
3739
return None
3840

3941

40-
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]:
42+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any, HTTPStatus]:
4143
return Response(
4244
status_code=HTTPStatus(response.status_code),
4345
content=response.content,
@@ -50,7 +52,7 @@ def sync_detailed(
5052
*,
5153
client: AuthenticatedClient | Client,
5254
common: str | Unset = UNSET,
53-
) -> Response[Any]:
55+
) -> Response[Any, HTTPStatus]:
5456
"""
5557
Args:
5658
common (str | Unset):
@@ -78,7 +80,7 @@ async def asyncio_detailed(
7880
*,
7981
client: AuthenticatedClient | Client,
8082
common: str | Unset = UNSET,
81-
) -> Response[Any]:
83+
) -> Response[Any, HTTPStatus]:
8284
"""
8385
Args:
8486
common (str | Unset):

end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_allof.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from http import HTTPStatus
1+
import http
22
from typing import Any
33

44
import httpx
@@ -8,6 +8,8 @@
88
from ...models.get_models_allof_response_200 import GetModelsAllofResponse200
99
from ...types import Response
1010

11+
HTTPStatus = http.HTTPStatus
12+
1113

1214
def _get_kwargs() -> dict[str, Any]:
1315
_kwargs: dict[str, Any] = {
@@ -34,7 +36,7 @@ def _parse_response(
3436

3537
def _build_response(
3638
*, client: AuthenticatedClient | Client, response: httpx.Response
37-
) -> Response[GetModelsAllofResponse200]:
39+
) -> Response[GetModelsAllofResponse200, HTTPStatus]:
3840
return Response(
3941
status_code=HTTPStatus(response.status_code),
4042
content=response.content,
@@ -46,7 +48,7 @@ def _build_response(
4648
def sync_detailed(
4749
*,
4850
client: AuthenticatedClient | Client,
49-
) -> Response[GetModelsAllofResponse200]:
51+
) -> Response[GetModelsAllofResponse200, HTTPStatus]:
5052
"""
5153
Raises:
5254
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -86,7 +88,7 @@ def sync(
8688
async def asyncio_detailed(
8789
*,
8890
client: AuthenticatedClient | Client,
89-
) -> Response[GetModelsAllofResponse200]:
91+
) -> Response[GetModelsAllofResponse200, HTTPStatus]:
9092
"""
9193
Raises:
9294
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from http import HTTPStatus
1+
import http
22
from typing import Any
33

44
import httpx
@@ -13,6 +13,8 @@
1313
)
1414
from ...types import Response
1515

16+
HTTPStatus = http.HTTPStatus
17+
1618

1719
def _get_kwargs() -> dict[str, Any]:
1820
_kwargs: dict[str, Any] = {
@@ -57,7 +59,9 @@ def _parse_response_200(
5759

5860
def _build_response(
5961
*, client: AuthenticatedClient | Client, response: httpx.Response
60-
) -> Response[GetModelsOneofWithRequiredConstResponse200Type0 | GetModelsOneofWithRequiredConstResponse200Type1]:
62+
) -> Response[
63+
GetModelsOneofWithRequiredConstResponse200Type0 | GetModelsOneofWithRequiredConstResponse200Type1, HTTPStatus
64+
]:
6165
return Response(
6266
status_code=HTTPStatus(response.status_code),
6367
content=response.content,
@@ -69,7 +73,9 @@ def _build_response(
6973
def sync_detailed(
7074
*,
7175
client: AuthenticatedClient | Client,
72-
) -> Response[GetModelsOneofWithRequiredConstResponse200Type0 | GetModelsOneofWithRequiredConstResponse200Type1]:
76+
) -> Response[
77+
GetModelsOneofWithRequiredConstResponse200Type0 | GetModelsOneofWithRequiredConstResponse200Type1, HTTPStatus
78+
]:
7379
"""
7480
Raises:
7581
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -109,7 +115,9 @@ def sync(
109115
async def asyncio_detailed(
110116
*,
111117
client: AuthenticatedClient | Client,
112-
) -> Response[GetModelsOneofWithRequiredConstResponse200Type0 | GetModelsOneofWithRequiredConstResponse200Type1]:
118+
) -> Response[
119+
GetModelsOneofWithRequiredConstResponse200Type0 | GetModelsOneofWithRequiredConstResponse200Type1, HTTPStatus
120+
]:
113121
"""
114122
Raises:
115123
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

0 commit comments

Comments
 (0)