8000 Update integration tests to check multiple files · micha91/openapi-python-client@14bed92 · GitHub
[go: up one dir, main page]

Skip to content

Commit 14bed92

Browse filesBrowse files
committed
Update integration tests to check multiple files
1 parent 0f8c7fe commit 14bed92

File tree

8 files changed

+163
-117
lines changed

8 files changed

+163
-117
lines changed

end_to_end_tests/test_end_to_end.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def test_generate_dir_already_exists():
266266

267267

268268
def test_update_integration_tests():
269-
url = "https://raw.githubusercontent.com/openapi-generators/openapi-test-server/main/openapi.json"
269+
url = "https://raw.githubusercontent.com/openapi-generators/openapi-test-server/main/openapi.yaml"
270270
source_path = Path(__file__).parent.parent / "integration-tests"
271271
temp_dir = Path.cwd() / "test_update_integration_tests"
272272
shutil.rmtree(temp_dir, ignore_errors=True)

integration-tests/integration_tests/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
from .post_body_multipart_body import PostBodyMultipartBody
44
from .post_body_multipart_response_200 import PostBodyMultipartResponse200
5+
from .post_body_multipart_response_200_files_item import PostBodyMultipartResponse200FilesItem
56
from .post_parameters_header_response_200 import PostParametersHeaderResponse200
67
from .problem import Problem
78
from .public_error import PublicError
89

910
__all__ = (
1011
"PostBodyMultipartBody",
1112
"PostBodyMultipartResponse200",
13+
"PostBodyMultipartResponse200FilesItem",
1214
"PostParametersHeaderResponse200",
1315
"Problem",
1416
"PublicError",

integration-tests/integration_tests/models/post_body_multipart_body.py

Lines changed: 24 additions & 17 deletions
10000
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from collections.abc import Mapping
22
from io import BytesIO
3-
from typing import Any, TypeVar, Union
3+
from typing import Any, TypeVar
44

55
from attrs import define as _attrs_define
66
from attrs import field as _attrs_field
77

8-
from ..types import UNSET, File, Unset
8+
from ..types import File
99

1010
T = TypeVar("T", bound="PostBodyMultipartBody")
1111

@@ -15,20 +15,23 @@ class PostBodyMultipartBody:
1515
"""
1616
Attributes:
1717
a_string (str):
18-
file (File): For the sake of this test, include a file name and content type. The payload should also be valid
19-
UTF-8.
20-
description (Union[Unset, str]):
18+
files (list[File]):
19+
description (str):
2120
"""
2221

2322
a_string: str
24-
file: File
25-
description: Union[Unset, str] = UNSET
23+
files: list[File]
24+
description: str
2625
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
2726

2827
def to_dict(self) -> dict[str, Any]:
2928
a_string = self.a_string
3029

31-
file = self.file.to_tuple()
30+
files = []
31+
for files_item_data in self.files:
32+
files_item = files_item_data.to_tuple()
33+
34+
files.append(files_item)
3235

3336
description = self.description
3437

@@ -37,11 +40,10 @@ def to_dict(self) -> dict[str, Any]:
3740
field_dict.update(
3841
{
3942
"a_string": a_string,
40-
"file": file,
43+
"files": files,
44+
"description": description,
4145
}
4246
)
43-
if description is not UNSET:
44-
field_dict["description"] = description
4547

4648
return field_dict
4749

@@ -50,10 +52,10 @@ def to_multipart(self) -> list[tuple[str, Any]]:
5052

5153
field_list.append(("a_string", (None, str(self.a_string).encode(), "text/plain")))
5254

53-
field_list.append(("file", self.file.to_tuple()))
55+
for files_item_element in self.files:
56+
field_list.append(("files", files_item_element.to_tuple()))
5457

55-
if not isinstance(self.description, Unset):
56-
field_list.append(("description", (None, str(self.description).encode(), "text/plain")))
58+
field_list.append(("description", (None, str(self.description).encode(), "text/plain")))
5759

5860
for prop_name, prop in self.additional_properties.items():
5961
field_list.append((prop_name, (None, str(prop).encode(), "text/plain")))
@@ -65,13 +67,18 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
6567
d = dict(src_dict)
6668
a_string = d.pop("a_string")
6769

68-
file = File(payload=BytesIO(d.pop("file")))
70+
files = []
71+
_files = d.pop("files")
72+
for files_item_data in _files:
73+
files_item = File(payload=BytesIO(files_item_data))
74+
75+
files.append(files_item)
6976

70-
description = d.pop("description", UNSET)
77+
description = d.pop("description")
7178

7279
post_body_multipart_body = cls(
7380
a_string=a_string,
74-
file=file,
81+
files=files,
7582
description=description,
7683
)
7784

integration-tests/integration_tests/models/post_body_multipart_response_200.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
from collections.abc import Mapping
2-
from typing import Any, TypeVar
2+
from typing import TYPE_CHECKING, Any, TypeVar
33

44
from attrs import define as _attrs_define
55
from attrs import field as _attrs_field
66

7+
if TYPE_CHECKING:
8+
from ..models.post_body_multipart_response_200_files_item import PostBodyMultipartResponse200FilesItem
9+
10+
711
T = TypeVar("T", bound="PostBodyMultipartResponse200")
812

913

@@ -12,63 +16,57 @@ class PostBodyMultipartResponse200:
1216
"""
1317
Attributes:
1418
a_string (str): Echo of the 'a_string' input parameter from the form.
15-
file_data (str): Echo of content of the 'file' input parameter from the form.
1619
description (str): Echo of the 'description' input parameter from the form.
17-
file_name (str): The name of the file uploaded.
18-
file_content_type (str): The content type of the file uploaded.
20+
files (list['PostBodyMultipartResponse200FilesItem']):
1921
"""
2022

2123
a_string: str
22-
file_data: str
2324
description: str
24-
file_name: str
25-
file_content_type: str
25+
files: list["PostBodyMultipartResponse200FilesItem"]
2626
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
2727

2828
def to_dict(self) -> dict[str, Any]:
2929
a_string = self.a_string
3030

31-
file_data = self.file_data
32-
3331
description = self.description
3432

35-
file_name = self.file_name
36-
37-
file_content_type = self.file_content_type
33+
files = []
34+
for files_item_data in self.files:
35+
files_item = files_item_data.to_dict()
36+
files.append(files_item)
3837

3938
field_dict: dict[str, Any] = {}
4039
field_dict.update(self.additional_properties)
4140
field_dict.update(
4241
{
4342
"a_string": a_string,
44-
"file_data": file_data,
4543
"description": description,
46-
"file_name": file_name,
47-
"file_content_type": file_content_type,
44+
"files": files,
4845
}
4946
)
5047

5148
return field_dict
5249

5350
@classmethod
5451
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
52+
from ..models.post_body_multipart_response_200_files_item import PostBodyMultipartResponse200FilesItem
53+
5554
d = dict(src_dict)
5655
a_string = d.pop("a_string")
5756

58-
file_data = d.pop("file_data")
59-
6057
description = d.pop("description")
6158

62-
file_name = d.pop("file_name")
59+
files = []
60+
_files = d.pop("files")
61+
for files_item_data in _files:
62+
files_item = PostBodyMultipartResponse200FilesItem.from_dict(files_item_data)
6363

64-
file_content_type = d.pop("file_content_type")
64+
files.append(files_item)
6565

6666
post_body_multipart_response_200 = cls(
6767
a_string=a_string,
68-
file_data=file_data,
6968
description=description,
70-
file_name=file_name,
71-
file_content_type=file_content_type,
69+
files=files,
7270
)
7371

7472
post_body_multipart_response_200.additional_properties = d
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
from collections.abc import Mapping
2+
from typing import Any, TypeVar, Union
3+
4+
from attrs import define as _attrs_define
5+
from attrs import field as _attrs_field
6+
7+
from ..types import UNSET, Unset
8+
9+
T = TypeVar("T", bound="PostBodyMultipartResponse200FilesItem")
10+
11+
12+
@_attrs_define
13+
class PostBodyMultipartResponse200FilesItem:
14+
"""
15+
Attributes:
16+
data (Union[Unset, str]): Echo of content of the 'file' input parameter from the form.
17+
name (Union[Unset, str]): The name of the file uploaded.
18+
content_type (Union[Unset, str]): The content type of the file uploaded.
19+
"""
20+
21+
data: Union[Unset, str] = UNSET
22+
name: Union[Unset, str] = UNSET
23+
content_type: Union[Unset, str] = UNSET
24+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
25+
26+
def to_dict(self) -> dict[str, Any]:
27+
data = self.data
28+
29+
name = self.name
30+
31+
content_type = self.content_type
32+
33+
field_dict: dict[str, Any] = {}
34+
field_dict.update(self.additional_properties)
35+
field_dict.update({})
36+
if data is not UNSET:
37+
field_dict["data"] = data
38+
if name is not UNSET:
39+
field_dict["name"] = name
40+
if content_type is not UNSET:
41+
field_dict["content_type"] = content_type
42+
43+
return field_dict
44+
45+
@classmethod
46+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
47+
d = dict(src_dict)
48+
data = d.pop("data", UNSET)
49+
50+
name = d.pop("name", UNSET)
51+
52+
content_type = d.pop("content_type", UNSET)
53+
54+
post_body_multipart_response_200_files_item = cls(
55+
data=data,
56+
name=name,
57+
content_type=content_type,
58+
)
59+
60+
post_body_multipart_response_200_files_item.additional_properties = d
61+
return post_body_multipart_response_200_files_item
62+
63+
@property
64+
def additional_keys(self) -> list[str]:
65+
return list(self.additional_properties.keys())
66+
67+
def __getitem__(self, key: str) -> Any:
68+
return self.additional_properties[key]
69+
70+
def __setitem__(self, key: str, value: Any) -> None:
71+
self.additional_properties[key] = value
72+
73+
def __delitem__(self, key: str) -> None:
74+
del self.additional_properties[key]
75+
76+
def __contains__(self, key: str) -> bool:
77+
return key in self.additional_properties

integration-tests/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "integration-tests"
3-
version = "0.0.1"
3+
version = "0.1.0"
44
description = "A client library for accessing OpenAPI Test Server"
55
authors = []
66
readme = "README.md"

0 commit comments

Comments
 (0)
0