Skip to content

Commit 0747bb7

Browse files
committed
chore: Regen integration test client and add to regen task
1 parent b89ad8d commit 0747bb7

File tree

7 files changed

+71
-13
lines changed

7 files changed

+71
-13
lines changed

CONTRIBUTING.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121

2222
2. When in a Poetry shell (`poetry shell`) run `task check` in order to run most of the same checks CI runs. This will auto-reformat the code, check type annotations, run unit tests, check code coverage, and lint the code.
2323

24-
### Rework end to end tests
24+
### Rework end-to-end tests
2525

26-
3. If you're writing a new feature, try to add it to the end to end test.
26+
3. If you're writing a new feature, try to add it to the end-to-end test.
2727
1. If adding support for a new OpenAPI feature, add it somewhere in `end_to_end_tests/openapi.json`
28-
2. Regenerate the "golden records" with `task regen`. This client is generated from the OpenAPI document used for end to end testing.
28+
2. Regenerate the "golden records" with `task regen`. This client is generated from the OpenAPI document used for end-to-end testing.
2929
3. Check the changes to `end_to_end_tests/golden-record` to confirm only what you intended to change did change and that the changes look correct.
30-
4. Run the end to end tests with `task e2e`. This will generate clients against `end_to_end_tests/openapi.json` and compare them with the golden record. The tests will fail if **anything is different**. The end to end tests are not included in `task check` as they take longer to run and don't provide very useful feedback in the event of failure. If an e2e test does fail, the easiest way to check what's wrong is to run `task regen` and check the diffs. You can also use `task re` which will run `regen` and `e2e` in that order.
30+
4. **If you added a test above OR modified the templates**: Run the end-to-end tests with `task e2e`. This will generate clients against `end_to_end_tests/openapi.json` and compare them with the golden record. The tests will fail if **anything is different**. The end-to-end tests are not included in `task check` as they take longer to run and don't provide very useful feedback in the event of failure. If an e2e test does fail, the easiest way to check what's wrong is to run `task regen` and check the diffs. You can also use `task re` which will run `regen` and `e2e` in that order.
31+
3132

3233
## Creating a Pull Request
3334

integration_tests/open-api-test-server-client/open_api_test_server_client/api/body/post_body_multipart.py

+33-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def _get_kwargs(
2222
multipart_multipart_data = multipart_data.to_multipart()
2323

2424
return {
25+
"method": "post",
2526
"url": url,
2627
"headers": headers,
2728
"cookies": cookies,
@@ -56,12 +57,20 @@ def sync_detailed(
5657
client: Client,
5758
multipart_data: PostBodyMultipartMultipartData,
5859
) -> Response[Union[PostBodyMultipartResponse200, PublicError]]:
60+
"""
61+
Args:
62+
multipart_data (PostBodyMultipartMultipartData):
63+
64+
Returns:
65+
Response[Union[PostBodyMultipartResponse200, PublicError]]
66+
"""
67+
5968
kwargs = _get_kwargs(
6069
client=client,
6170
multipart_data=multipart_data,
6271
)
6372

64-
response = httpx.post(
73+
response = httpx.request(
6574
verify=client.verify_ssl,
6675
**kwargs,
6776
)
@@ -74,7 +83,13 @@ def sync(
7483
client: Client,
7584
multipart_data: PostBodyMultipartMultipartData,
7685
) -> Optional[Union[PostBodyMultipartResponse200, PublicError]]:
77-
""" """
86+
"""
87+
Args:
88+
multipart_data (PostBodyMultipartMultipartData):
89+
90+
Returns:
91+
Response[Union[PostBodyMultipartResponse200, PublicError]]
92+
"""
7893

7994
return sync_detailed(
8095
client=client,
@@ -87,13 +102,21 @@ async def asyncio_detailed(
87102
client: Client,
88103
multipart_data: PostBodyMultipartMultipartData,
89104
) -> Response[Union[PostBodyMultipartResponse200, PublicError]]:
105+
"""
106+
Args:
107+
multipart_data (PostBodyMultipartMultipartData):
108+
109+
Returns:
110+
Response[Union[PostBodyMultipartResponse200, PublicError]]
111+
"""
112+
90113
kwargs = _get_kwargs(
91114
client=client,
92115
multipart_data=multipart_data,
93116
)
94117

95118
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
96-
response = await _client.post(**kwargs)
119+
response = await _client.request(**kwargs)
97120

98121
return _build_response(response=response)
99122

@@ -103,7 +126,13 @@ async def asyncio(
103126
client: Client,
104127
multipart_data: PostBodyMultipartMultipartData,
105128
) -> Optional[Union[PostBodyMultipartResponse200, PublicError]]:
106-
""" """
129+
"""
130+
Args:
131+
multipart_data (PostBodyMultipartMultipartData):
132+
133+
Returns:
134+
Response[Union[PostBodyMultipartResponse200, PublicError]]
135+
"""
107136

108137
return (
109138
await asyncio_detailed(

integration_tests/open-api-test-server-client/open_api_test_server_client/models/post_body_multipart_multipart_data.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010

1111
@attr.s(auto_attribs=True)
1212
class PostBodyMultipartMultipartData:
13-
""" """
13+
"""
14+
Attributes:
15+
a_string (str):
16+
file (File): For the sake of this test, include a file name and content type. The payload should also be valid
17+
UTF-8.
18+
description (Union[Unset, str]):
19+
"""
1420

1521
a_string: str
1622
file: File

integration_tests/open-api-test-server-client/open_api_test_server_client/models/post_body_multipart_response_200.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
@attr.s(auto_attribs=True)
99
class PostBodyMultipartResponse200:
10-
""" """
10+
"""
11+
Attributes:
12+
a_string (str): Echo of the 'a_string' input parameter from the form.
13+
file_data (str): Echo of content of the 'file' input parameter from the form.
14+
description (str): Echo of the 'description' input parameter from the form.
15+
file_name (str): The name of the file uploaded.
16+
file_content_type (str): The content type of the file uploaded.
17+
"""
1118

1219
a_string: str
1320
file_data: str

integration_tests/open-api-test-server-client/open_api_test_server_client/models/problem.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010
@attr.s(auto_attribs=True)
1111
class Problem:
12-
""" """
12+
"""
13+
Attributes:
14+
parameter_name (Union[Unset, str]):
15+
description (Union[Unset, str]):
16+
"""
1317

1418
parameter_name: Union[Unset, str] = UNSET
1519
description: Union[Unset, str] = UNSET

integration_tests/open-api-test-server-client/open_api_test_server_client/models/public_error.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010

1111
@attr.s(auto_attribs=True)
1212
class PublicError:
13-
""" """
13+
"""
14+
Attributes:
15+
errors (Union[Unset, List[str]]):
16+
extra_parameters (Union[Unset, List[str]]):
17+
invalid_parameters (Union[Unset, List[Problem]]):
18+
missing_parameters (Union[Unset, List[str]]):
19+
"""
1420

1521
errors: Union[Unset, List[str]] = UNSET
1622
extra_parameters: Union[Unset, List[str]] = UNSET

pyproject.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ isort .\
6565
&& TASKIPY=true pytest --cov openapi_python_client tests --cov-report=term-missing --basetemp=tests/tmp\
6666
&& rm -r tests/tmp\
6767
"""
68-
regen = "python -m end_to_end_tests.regen_golden_record"
68+
regen = """
69+
python -m end_to_end_tests.regen_golden_record\
70+
&& pushd integration_tests\
71+
&& openapi-python-client update --url https://raw.githubusercontent.com/openapi-generators/openapi-test-server/main/openapi.json\
72+
&& popd
73+
"""
6974
e2e = "pytest openapi_python_client end_to_end_tests/test_end_to_end.py"
7075
re = """
7176
task regen\

0 commit comments

Comments
 (0)