Skip to content

Commit 0afaacd

Browse files
committed
Fix integration tests
1 parent 13bf2e8 commit 0afaacd

File tree

8 files changed

+292
-48
lines changed

8 files changed

+292
-48
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
"""Contains all the data models used in inputs/outputs"""
22

3+
from .an_object import AnObject
4+
from .file import File
35
from .post_body_multipart_body import PostBodyMultipartBody
46
from .post_body_multipart_response_200 import PostBodyMultipartResponse200
57
from .post_parameters_header_response_200 import PostParametersHeaderResponse200
68
from .problem import Problem
79
from .public_error import PublicError
810

911
__all__ = (
12+
"AnObject",
13+
"File",
1014
"PostBodyMultipartBody",
1115
"PostBodyMultipartResponse200",
1216
"PostParametersHeaderResponse200",
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from collections.abc import Mapping
2+
from typing import Any, TypeVar
3+
4+
from attrs import define as _attrs_define
5+
from attrs import field as _attrs_field
6+
7+
T = TypeVar("T", bound="AnObject")
8+
9+
10+
@_attrs_define
11+
class AnObject:
12+
"""
13+
Attributes:
14+
an_int (int):
15+
a_float (float):
16+
"""
17+
18+
an_int: int
19+
a_float: float
20+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
21+
22+
def to_dict(self) -> dict[str, Any]:
23+
an_int = self.an_int
24+
25+
a_float = self.a_float
26+
27+
field_dict: dict[str, Any] = {}
28+
field_dict.update(self.additional_properties)
29+
field_dict.update(
30+
{
31+
"an_int": an_int,
32+
"a_float": a_float,
33+
}
34+
)
35+
36+
return field_dict
37+
38+
@classmethod
39+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
40+
d = dict(src_dict)
41+
an_int = d.pop("an_int")
42+
43+
a_float = d.pop("a_float")
44+
45+
an_object = cls(
46+
an_int=an_int,
47+
a_float=a_float,
48+
)
49+
50+
an_object.additional_properties = d
51+
return an_object
52+
53+
@property
54+
def additional_keys(self) -> list[str]:
55+
return list(self.additional_properties.keys())
56+
57+
def __getitem__(self, key: str) -> Any:
58+
return self.additional_properties[key]
59+
60+
def __setitem__(self, key: str, value: Any) -> None:
61+
self.additional_properties[key] = value
62+
63+
def __delitem__(self, key: str) -> None:
64+
del self.additional_properties[key]
65+
66+
def __contains__(self, key: str) -> bool:
67+
return key in self.additional_properties
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="File")
10+
11+
12+
@_attrs_define
13+
class File:
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+
file = cls(
55+
data=data,
56+
name=name,
57+
content_type=content_type,
58+
)
59+
60+
file.additional_properties = d
61+
return file
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/integration_tests/models/post_body_multipart_body.py

Lines changed: 85 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
import datetime
2+
import json
13
from collections.abc import Mapping
24
from io import BytesIO
3-
from typing import Any, TypeVar, Union
5+
from typing import TYPE_CHECKING, Any, TypeVar
46

57
from attrs import define as _attrs_define
68
from attrs import field as _attrs_field
9+
from dateutil.parser import isoparse
10+
11+
from ..types import File
12+
13+
if TYPE_CHECKING:
14+
from ..models.an_object import AnObject
715

8-
from ..types import UNSET, File, Unset
916

1017
T = TypeVar("T", bound="PostBodyMultipartBody")
1118

@@ -15,46 +22,77 @@ class PostBodyMultipartBody:
1522
"""
1623
Attributes:
1724
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]):
25+
files (list[File]):
26+
description (str):
27+
objects (list['AnObject']):
28+
times (list[datetime.datetime]):
2129
"""
2230

2331
a_string: str
24-
file: File
25-
description: Union[Unset, str] = UNSET
32+
files: list[File]
33+
description: str
34+
objects: list["AnObject"]
35+
times: list[datetime.datetime]
2636
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
2737

2838
def to_dict(self) -> dict[str, Any]:
2939
a_string = self.a_string
3040

31-
file = self.file.to_tuple()
41+
files = []
42+
for files_item_data in self.files:
43+
files_item = files_item_data.to_tuple()
44+
45+
files.append(files_item)
3246

3347
description = self.description
3448

49+
objects = []
50+
for objects_item_data in self.objects:
51+
objects_item = objects_item_data.to_dict()
52+
objects.append(objects_item)
53+
54+
times = []
55+
for times_item_data in self.times:
56+
times_item = times_item_data.isoformat()
57+
times.append(times_item)
58+
3559
field_dict: dict[str, Any] = {}
3660
field_dict.update(self.additional_properties)
3761
field_dict.update(
3862
{
3963
"a_string": a_string,
40-
"file": file,
64+
"files": files,
65+
"description": description,
66+
"objects": objects,
67+
"times": times,
4168
}
4269
)
43-
if description is not UNSET:
44-
field_dict["description"] = description
4570

4671
return field_dict
4772

4873
def to_multipart(self) -> dict[str, Any]:
4974
a_string = (None, str(self.a_string).encode(), "text/plain")
5075

51-
file = self.file.to_tuple()
76+
_temp_files = []
77+
for files_item_data in self.files:
78+
files_item = files_item_data.to_tuple()
5279

53-
description = (
54-
self.description
55-
if isinstance(self.description, Unset)
56-
else (None, str(self.description).encode(), "text/plain")
57-
)
80+
_temp_files.append(files_item)
81+
files = (None, json.dumps(_temp_files).encode(), "application/json")
82+
83+
description = (None, str(self.description).encode(), "text/plain")
84+
85+
_temp_objects = []
86+
for objects_item_data in self.objects:
87+
objects_item = objects_item_data.to_dict()
88+
_temp_objects.append(objects_item)
89+
objects = (None, json.dumps(_temp_objects).encode(), "application/json")
90+
91+
_temp_times = []
92+
for times_item_data in self.times:
93+
times_item = times_item_data.isoformat()
94+
_temp_times.append(times_item)
95+
times = (None, json.dumps(_temp_times).encode(), "application/json")
5896

5997
field_dict: dict[str, Any] = {}
6098
for prop_name, prop in self.additional_properties.items():
@@ -63,27 +101,51 @@ def to_multipart(self) -> dict[str, Any]:
63101
field_dict.update(
64102
{
65103
"a_string": a_string,
66-
"file": file,
104+
"files": files,
105+
"description": description,
106+
"objects": objects,
107+
"times": times,
67108
}
68109
)
69-
if description is not UNSET:
70-
field_dict["description"] = description
71110

72111
return field_dict
73112

74113
@classmethod
75114
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
115+
from ..models.an_object import AnObject
116+
76117
d = dict(src_dict)
77118
a_string = d.pop("a_string")
78119

79-
file = File(payload=BytesIO(d.pop("file")))
120+
files = []
121+
_files = d.pop("files")
122+
for files_item_data in _files:
123+
files_item = File(payload=BytesIO(files_item_data))
124+
125+
files.append(files_item)
126+
127+
description = d.pop("description")
128+
129+
objects = []
130+
_objects = d.pop("objects")
131+
for objects_item_data in _objects:
132+
objects_item = AnObject.from_dict(objects_item_data)
133+
134+
objects.append(objects_item)
135+
136+
times = []
137+
_times = d.pop("times")
138+
for times_item_data in _times:
139+
times_item = isoparse(times_item_data)
80140

81-
description = d.pop("description", UNSET)
141+
times.append(times_item)
82142

83143
post_body_multipart_body = cls(
84144
a_string=a_string,
85-
file=file,
145+
files=files,
86146
description=description,
147+
objects=objects,
148+
times=times,
87149
)
88150

89151
post_body_multipart_body.additional_properties = d

0 commit comments

Comments
 (0)