Skip to content

Fix integration tests #1265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion end_to_end_tests/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def test_generate_dir_already_exists():


def test_update_integration_tests():
url = "https://raw.githubusercontent.com/openapi-generators/openapi-test-server/main/openapi.json"
url = "https://raw.githubusercontent.com/openapi-generators/openapi-test-server/main/openapi.yaml"
source_path = Path(__file__).parent.parent / "integration-tests"
temp_dir = Path.cwd() / "test_update_integration_tests"
shutil.rmtree(temp_dir, ignore_errors=True)
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/integration_tests/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
"""Contains all the data models used in inputs/outputs"""

from .an_object import AnObject
from .file import File
from .post_body_multipart_body import PostBodyMultipartBody
from .post_body_multipart_response_200 import PostBodyMultipartResponse200
from .post_parameters_header_response_200 import PostParametersHeaderResponse200
from .problem import Problem
from .public_error import PublicError

__all__ = (
"AnObject",
"File",
"PostBodyMultipartBody",
"PostBodyMultipartResponse200",
"PostParametersHeaderResponse200",
Expand Down
67 changes: 67 additions & 0 deletions integration-tests/integration_tests/models/an_object.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from collections.abc import Mapping
from typing import Any, TypeVar

from attrs import define as _attrs_define
from attrs import field as _attrs_field

T = TypeVar("T", bound="AnObject")


@_attrs_define
class AnObject:
"""
Attributes:
an_int (int):
a_float (float):
"""

an_int: int
a_float: float
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

def to_dict(self) -> dict[str, Any]:
an_int = self.an_int

a_float = self.a_float

field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"an_int": an_int,
"a_float": a_float,
}
)

return field_dict

@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
an_int = d.pop("an_int")

a_float = d.pop("a_float")

an_object = cls(
an_int=an_int,
a_float=a_float,
)

an_object.additional_properties = d
return an_object

@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())

def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]

def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value

def __delitem__(self, key: str) -> None:
del self.additional_properties[key]

def __contains__(self, key: str) -> bool:
return key in self.additional_properties
77 changes: 77 additions & 0 deletions integration-tests/integration_tests/models/file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
from collections.abc import Mapping
from typing import Any, TypeVar, Union

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

T = TypeVar("T", bound="File")


@_attrs_define
class File:
"""
Attributes:
data (Union[Unset, str]): Echo of content of the 'file' input parameter from the form.
name (Union[Unset, str]): The name of the file uploaded.
content_type (Union[Unset, str]): The content type of the file uploaded.
"""

data: Union[Unset, str] = UNSET
name: Union[Unset, str] = UNSET
content_type: Union[Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

def to_dict(self) -> dict[str, Any]:
data = self.data

name = self.name

content_type = self.content_type

field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if data is not UNSET:
field_dict["data"] = data
if name is not UNSET:
field_dict["name"] = name
if content_type is not UNSET:
field_dict["content_type"] = content_type

return field_dict

@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
data = d.pop("data", UNSET)

name = d.pop("name", UNSET)

content_type = d.pop("content_type", UNSET)

file = cls(
data=data,
name=name,
content_type=content_type,
)

file.additional_properties = d
return file

@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())

def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]

def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value

def __delitem__(self, key: str) -> None:
del self.additional_properties[key]

def __contains__(self, key: str) -> bool:
return key in self.additional_properties
108 changes: 85 additions & 23 deletions integration-tests/integration_tests/models/post_body_multipart_body.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import datetime
import json
from collections.abc import Mapping
from io import BytesIO
from typing import Any, TypeVar, Union
from typing import TYPE_CHECKING, Any, TypeVar

from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse

from ..types import File

if TYPE_CHECKING:
from ..models.an_object import AnObject

from ..types import UNSET, File, Unset

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

Expand All @@ -15,46 +22,77 @@ class PostBodyMultipartBody:
"""
Attributes:
a_string (str):
file (File): For the sake of this test, include a file name and content type. The payload should also be valid
UTF-8.
description (Union[Unset, str]):
files (list[File]):
description (str):
objects (list['AnObject']):
times (list[datetime.datetime]):
"""

a_string: str
file: File
description: Union[Unset, str] = UNSET
files: list[File]
description: str
objects: list["AnObject"]
times: list[datetime.datetime]
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

file = self.file.to_tuple()
files = []
for files_item_data in self.files:
files_item = files_item_data.to_tuple()

files.append(files_item)

description = self.description

objects = []
for objects_item_data in self.objects:
objects_item = objects_item_data.to_dict()
objects.append(objects_item)

times = []
for times_item_data in self.times:
times_item = times_item_data.isoformat()
times.append(times_item)

field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"a_string": a_string,
"file": file,
"files": files,
"description": description,
"objects": objects,
"times": times,
}
)
if description is not UNSET:
field_dict["description"] = description

return field_dict

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

file = self.file.to_tuple()
_temp_files = []
for files_item_data in self.files:
files_item = files_item_data.to_tuple()

description = (
self.description
if isinstance(self.description, Unset)
else (None, str(self.description).encode(), "text/plain")
)
_temp_files.append(files_item)
files = (None, json.dumps(_temp_files).encode(), "application/json")

description = (None, str(self.description).encode(), "text/plain")

_temp_objects = []
for objects_item_data in self.objects:
objects_item = objects_item_data.to_dict()
_temp_objects.append(objects_item)
objects = (None, json.dumps(_temp_objects).encode(), "application/json")

_temp_times = []
for times_item_data in self.times:
times_item = times_item_data.isoformat()
_temp_times.append(times_item)
times = (None, json.dumps(_temp_times).encode(), "application/json")

field_dict: dict[str, Any] = {}
for prop_name, prop in self.additional_properties.items():
Expand All @@ -63,27 +101,51 @@ def to_multipart(self) -> dict[str, Any]:
field_dict.update(
{
"a_string": a_string,
"file": file,
"files": files,
"description": description,
"objects": objects,
"times": times,
}
)
if description is not UNSET:
field_dict["description"] = description

return field_dict

@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.an_object import AnObject

d = dict(src_dict)
a_string = d.pop("a_string")

file = File(payload=BytesIO(d.pop("file")))
files = []
_files = d.pop("files")
for files_item_data in _files:
files_item = File(payload=BytesIO(files_item_data))

files.append(files_item)

description = d.pop("description")

objects = []
_objects = d.pop("objects")
for objects_item_data in _objects:
objects_item = AnObject.from_dict(objects_item_data)

objects.append(objects_item)

times = []
_times = d.pop("times")
for times_item_data in _times:
times_item = isoparse(times_item_data)

description = d.pop("description", UNSET)
times.append(times_item)

post_body_multipart_body = cls(
a_string=a_string,
file=file,
files=files,
description=description,
objects=objects,
times=times,
)

post_body_multipart_body.additional_properties = d
Expand Down
Loading
Loading