Skip to content

Commit 85c81be

Browse files
wing328changhc
andauthored
[python] Close test API clients (#20400)
* close api client * update samples * update python pydantic v1 test files * update python disallow additional property tests * update python tests * update python tests * update python aiohttp tests * update python pydantic aiohttp tests * update python pydantic v1 tests * revert sync teardown * update python disallow tests * update FILES * update python echo api tests * update python tests --------- Co-authored-by: Huan-Cheng Chang <[email protected]>
1 parent 43f59ba commit 85c81be

File tree

273 files changed

+3484
-3205
lines changed

Some content is hidden

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

273 files changed

+3484
-3205
lines changed

modules/openapi-generator/src/main/resources/python-pydantic-v1/api_test.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ class {{#operations}}Test{{classname}}(unittest.{{#asyncio}}IsolatedAsyncio{{/as
1515
self.api = {{classname}}()
1616

1717
async def asyncTearDown(self) -> None:
18-
pass
18+
await self.api.api_client.close()
1919
{{/asyncio}}
2020
{{^asyncio}}
2121
def setUp(self) -> None:
2222
self.api = {{classname}}()
2323

2424
def tearDown(self) -> None:
25-
pass
25+
self.api.api_client.close()
2626
{{/asyncio}}
2727

2828
{{#operation}}

modules/openapi-generator/src/main/resources/python/api_test.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class {{#operations}}Test{{classname}}(unittest.{{#asyncio}}IsolatedAsyncio{{/as
1515
self.api = {{classname}}()
1616

1717
async def asyncTearDown(self) -> None:
18-
pass
18+
await self.api.api_client.close()
1919
{{/asyncio}}
2020
{{^asyncio}}
2121
def setUp(self) -> None:

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/test/test_auth_api.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,29 @@
1515

1616
import unittest
1717

18-
from openapi_client.api.auth_api import AuthApi # noqa: E501
18+
from openapi_client.api.auth_api import AuthApi
1919

2020

2121
class TestAuthApi(unittest.TestCase):
2222
"""AuthApi unit test stubs"""
2323

2424
def setUp(self) -> None:
25-
self.api = AuthApi() # noqa: E501
25+
self.api = AuthApi()
2626

2727
def tearDown(self) -> None:
2828
pass
2929

3030
def test_test_auth_http_basic(self) -> None:
3131
"""Test case for test_auth_http_basic
3232
33-
To test HTTP basic authentication # noqa: E501
33+
To test HTTP basic authentication
34+
"""
35+
pass
36+
37+
def test_test_auth_http_bearer(self) -> None:
38+
"""Test case for test_auth_http_bearer
39+
40+
To test HTTP bearer authentication
3441
"""
3542
pass
3643

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/test/test_bird.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,19 @@
33
"""
44
Echo Server API
55
6-
Echo Server API # noqa: E501
6+
Echo Server API
77
88
The version of the OpenAPI document: 0.1.0
99
10-
Generated by: https://openapi-generator.tech
11-
"""
10+
Generated by OpenAPI Generator (https://openapi-generator.tech)
1211
12+
Do not edit the class manually.
13+
""" # noqa: E501
1314

14-
from __future__ import absolute_import
1515

1616
import unittest
17-
import datetime
1817

19-
import openapi_client
20-
from openapi_client.models.bird import Bird # noqa: E501
21-
from openapi_client.rest import ApiException
18+
from openapi_client.models.bird import Bird
2219

2320
class TestBird(unittest.TestCase):
2421
"""Bird unit test stubs"""
@@ -29,20 +26,20 @@ def setUp(self):
2926
def tearDown(self):
3027
pass
3128

32-
def make_instance(self, include_optional):
29+
def make_instance(self, include_optional) -> Bird:
3330
"""Test Bird
34-
include_option is a boolean, when False only required
31+
include_optional is a boolean, when False only required
3532
params are included, when True both required and
3633
optional params are included """
3734
# uncomment below to create an instance of `Bird`
3835
"""
39-
model = openapi_client.models.bird.Bird() # noqa: E501
40-
if include_optional :
36+
model = Bird()
37+
if include_optional:
4138
return Bird(
42-
size = '',
39+
size = '',
4340
color = ''
4441
)
45-
else :
42+
else:
4643
return Bird(
4744
)
4845
"""

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/test/test_body_api.py

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,97 @@
33
"""
44
Echo Server API
55
6-
Echo Server API # noqa: E501
6+
Echo Server API
77
88
The version of the OpenAPI document: 0.1.0
99
10-
Generated by: https://openapi-generator.tech
11-
"""
10+
Generated by OpenAPI Generator (https://openapi-generator.tech)
1211
12+
Do not edit the class manually.
13+
""" # noqa: E501
1314

14-
from __future__ import absolute_import
1515

1616
import unittest
1717

18-
import openapi_client
19-
from openapi_client.api.body_api import BodyApi # noqa: E501
20-
from openapi_client.rest import ApiException
18+
from openapi_client.api.body_api import BodyApi
2119

2220

2321
class TestBodyApi(unittest.TestCase):
2422
"""BodyApi unit test stubs"""
2523

26-
def setUp(self):
27-
self.api = openapi_client.api.body_api.BodyApi() # noqa: E501
24+
def setUp(self) -> None:
25+
self.api = BodyApi()
26+
27+
def tearDown(self) -> None:
28+
pass
29+
30+
def test_test_binary_gif(self) -> None:
31+
"""Test case for test_binary_gif
32+
33+
Test binary (gif) response body
34+
"""
35+
pass
36+
37+
def test_test_body_application_octetstream_binary(self) -> None:
38+
"""Test case for test_body_application_octetstream_binary
39+
40+
Test body parameter(s)
41+
"""
42+
pass
43+
44+
def test_test_body_multipart_formdata_array_of_binary(self) -> None:
45+
"""Test case for test_body_multipart_formdata_array_of_binary
46+
47+
Test array of binary in multipart mime
48+
"""
49+
pass
50+
51+
def test_test_body_multipart_formdata_single_binary(self) -> None:
52+
"""Test case for test_body_multipart_formdata_single_binary
53+
54+
Test single binary in multipart mime
55+
"""
56+
pass
57+
58+
def test_test_echo_body_all_of_pet(self) -> None:
59+
"""Test case for test_echo_body_all_of_pet
60+
61+
Test body parameter(s)
62+
"""
63+
pass
64+
65+
def test_test_echo_body_free_form_object_response_string(self) -> None:
66+
"""Test case for test_echo_body_free_form_object_response_string
2867
29-
def tearDown(self):
68+
Test free form object
69+
"""
3070
pass
3171

32-
def test_test_echo_body_pet(self):
72+
def test_test_echo_body_pet(self) -> None:
3373
"""Test case for test_echo_body_pet
3474
35-
Test body parameter(s) # noqa: E501
75+
Test body parameter(s)
76+
"""
77+
pass
78+
79+
def test_test_echo_body_pet_response_string(self) -> None:
80+
"""Test case for test_echo_body_pet_response_string
81+
82+
Test empty response body
83+
"""
84+
pass
85+
86+
def test_test_echo_body_string_enum(self) -> None:
87+
"""Test case for test_echo_body_string_enum
88+
89+
Test string enum response body
90+
"""
91+
pass
92+
93+
def test_test_echo_body_tag_response_string(self) -> None:
94+
"""Test case for test_echo_body_tag_response_string
95+
96+
Test empty json (request body)
3697
"""
3798
pass
3899

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/test/test_category.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,19 @@
33
"""
44
Echo Server API
55
6-
Echo Server API # noqa: E501
6+
Echo Server API
77
88
The version of the OpenAPI document: 0.1.0
99
10-
Generated by: https://openapi-generator.tech
11-
"""
10+
Generated by OpenAPI Generator (https://openapi-generator.tech)
1211
12+
Do not edit the class manually.
13+
""" # noqa: E501
1314

14-
from __future__ import absolute_import
1515

1616
import unittest
17-
import datetime
1817

19-
import openapi_client
20-
from openapi_client.models.category import Category # noqa: E501
21-
from openapi_client.rest import ApiException
18+
from openapi_client.models.category import Category
2219

2320
class TestCategory(unittest.TestCase):
2421
"""Category unit test stubs"""
@@ -29,20 +26,20 @@ def setUp(self):
2926
def tearDown(self):
3027
pass
3128

32-
def make_instance(self, include_optional):
29+
def make_instance(self, include_optional) -> Category:
3330
"""Test Category
34-
include_option is a boolean, when False only required
31+
include_optional is a boolean, when False only required
3532
params are included, when True both required and
3633
optional params are included """
3734
# uncomment below to create an instance of `Category`
3835
"""
39-
model = openapi_client.models.category.Category() # noqa: E501
40-
if include_optional :
36+
model = Category()
37+
if include_optional:
4138
return Category(
42-
id = 1,
39+
id = 1,
4340
name = 'Dogs'
4441
)
45-
else :
42+
else:
4643
return Category(
4744
)
4845
"""

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/test/test_data_query.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,19 @@
33
"""
44
Echo Server API
55
6-
Echo Server API # noqa: E501
6+
Echo Server API
77
88
The version of the OpenAPI document: 0.1.0
99
10-
Generated by: https://openapi-generator.tech
11-
"""
10+
Generated by OpenAPI Generator (https://openapi-generator.tech)
1211
12+
Do not edit the class manually.
13+
""" # noqa: E501
1314

14-
from __future__ import absolute_import
1515

1616
import unittest
17-
import datetime
1817

19-
import openapi_client
20-
from openapi_client.models.data_query import DataQuery # noqa: E501
21-
from openapi_client.rest import ApiException
18+
from openapi_client.models.data_query import DataQuery
2219

2320
class TestDataQuery(unittest.TestCase):
2421
"""DataQuery unit test stubs"""
@@ -29,21 +26,21 @@ def setUp(self):
2926
def tearDown(self):
3027
pass
3128

32-
def make_instance(self, include_optional):
29+
def make_instance(self, include_optional) -> DataQuery:
3330
"""Test DataQuery
34-
include_option is a boolean, when False only required
31+
include_optional is a boolean, when False only required
3532
params are included, when True both required and
3633
optional params are included """
3734
# uncomment below to create an instance of `DataQuery`
3835
"""
39-
model = openapi_client.models.data_query.DataQuery() # noqa: E501
40-
if include_optional :
36+
model = DataQuery()
37+
if include_optional:
4138
return DataQuery(
42-
suffix = '',
43-
text = 'Some text',
39+
suffix = '',
40+
text = 'Some text',
4441
var_date = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f')
4542
)
46-
else :
43+
else:
4744
return DataQuery(
4845
)
4946
"""

0 commit comments

Comments
 (0)