Skip to content

Commit 2ad1051

Browse files
Fix tests
2 parents f9788d7 + 55e16f3 commit 2ad1051

27 files changed

+148
-65
lines changed

end_to_end_tests/golden-record-custom/custom_e2e/api/tests/defaults_tests_defaults_post.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPVal
2323

2424
return response_200
2525
if response.status_code == 422:
26+
if not isinstance(response.json(), dict):
27+
raise ValueError("Cannot construct model from value " + str(response.json()))
2628
response_422 = HTTPValidationError.from_dict(response.json())
2729

2830
return response_422

end_to_end_tests/golden-record-custom/custom_e2e/api/tests/get_user_list.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ def _parse_response(*, response: httpx.Response) -> Optional[Union[List[AModel],
1919
response_200 = []
2020
_response_200 = response.json()
2121
for response_200_item_data in _response_200:
22+
if not isinstance(response_200_item_data, dict):
23+
raise ValueError("Cannot construct model from value " + str(response_200_item_data))
2224
response_200_item = AModel.from_dict(response_200_item_data)
2325

2426
response_200.append(response_200_item)
2527

2628
return response_200
2729
if response.status_code == 422:
30+
if not isinstance(response.json(), dict):
31+
raise ValueError("Cannot construct model from value " + str(response.json()))
2832
response_422 = HTTPValidationError.from_dict(response.json())
2933

3034
return response_422

end_to_end_tests/golden-record-custom/custom_e2e/api/tests/int_enum_tests_int_enum_post.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPVal
1818

1919
return response_200
2020
if response.status_code == 422:
21+
if not isinstance(response.json(), dict):
22+
raise ValueError("Cannot construct model from value " + str(response.json()))
2123
response_422 = HTTPValidationError.from_dict(response.json())
2224

2325
return response_422

end_to_end_tests/golden-record-custom/custom_e2e/api/tests/json_body_tests_json_body_post.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPVal
1616

1717
return response_200
1818
if response.status_code == 422:
19+
if not isinstance(response.json(), dict):
20+
raise ValueError("Cannot construct model from value " + str(response.json()))
1921
response_422 = HTTPValidationError.from_dict(response.json())
2022

2123
return response_422

end_to_end_tests/golden-record-custom/custom_e2e/api/tests/optional_value_tests_optional_query_param.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPVal
1818

1919
return response_200
2020
if response.status_code == 422:
21+
if not isinstance(response.json(), dict):
22+
raise ValueError("Cannot construct model from value " + str(response.json()))
2123
response_422 = HTTPValidationError.from_dict(response.json())
2224

2325
return response_422

end_to_end_tests/golden-record-custom/custom_e2e/api/tests/test_inline_objects.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
def _parse_response(*, response: httpx.Response) -> Optional[TestInlineObjectsResponse_200]:
1414
if response.status_code == 200:
15+
if not isinstance(response.json(), dict):
16+
raise ValueError("Cannot construct model from value " + str(response.json()))
1517
response_200 = TestInlineObjectsResponse_200.from_dict(response.json())
1618

1719
return response_200

end_to_end_tests/golden-record-custom/custom_e2e/api/tests/upload_file_tests_upload_post.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ def _parse_response(*, response: httpx.Response) -> Optional[Union[
2222

2323
return response_200
2424
if response.status_code == 422:
25+
if not isinstance(response.json(), dict):
26+
raise ValueError("Cannot construct model from value " + str(response.json()))
2527
response_422 = HTTPValidationError.from_dict(response.json())
2628

2729
return response_422

end_to_end_tests/golden-record-custom/custom_e2e/models/a_model.py

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,22 @@ def _parse_a_camel_date_time(data: Union[str]) -> Union[datetime.datetime, datet
182182

183183
required_not_nullable = d.pop("required_not_nullable")
184184

185+
if not isinstance(d.pop("model"), dict):
186+
raise ValueError("Cannot construct model from value " + str(d.pop("model")))
185187
model = AModelModel.from_dict(d.pop("model"))
186188

187189
def _parse_one_of_models(data: Union[Dict[str, Any]]) -> Union[FreeFormModel, ModelWithUnionProperty]:
188190
one_of_models: Union[FreeFormModel, ModelWithUnionProperty]
189191
try:
192+
if not isinstance(data, dict):
193+
raise ValueError("Cannot construct model from value " + str(data))
190194
one_of_models = FreeFormModel.from_dict(data)
191195

192196
return one_of_models
193197
except: # noqa: E722
194198
pass
199+
if not isinstance(data, dict):
200+
raise ValueError("Cannot construct model from value " + str(data))
195201
one_of_models = ModelWithUnionProperty.from_dict(data)
196202

197203
return one_of_models
@@ -224,19 +230,28 @@ def _parse_one_of_models(data: Union[Dict[str, Any]]) -> Union[FreeFormModel, Mo
224230
not_required_not_nullable = d.pop("not_required_not_nullable", UNSET)
225231

226232
nullable_model = None
227-
_nullable_model = d.pop("nullable_model")
228-
if _nullable_model is not None and not isinstance(_nullable_model, Unset):
229-
nullable_model = AModelNullableModel.from_dict(_nullable_model)
233+
if d.pop("nullable_model") is not None and not isinstance(d.pop("nullable_model"), Unset):
234+
if not isinstance(d.pop("nullable_model"), dict):
235+
raise ValueError("Cannot construct model from value " + str(d.pop("nullable_model")))
236+
nullable_model = AModelNullableModel.from_dict(d.pop("nullable_model"))
230237

231238
not_required_model: Union[Unset, AModelNotRequiredModel] = UNSET
232-
_not_required_model = d.pop("not_required_model", UNSET)
233-
if _not_required_model is not None and not isinstance(_not_required_model, Unset):
234-
not_required_model = AModelNotRequiredModel.from_dict(_not_required_model)
239+
if d.pop("not_required_model", UNSET) is not None and not isinstance(d.pop("not_required_model", UNSET), Unset):
240+
if not isinstance(d.pop("not_required_model", UNSET), dict):
241+
raise ValueError("Cannot construct model from value " + str(d.pop("not_required_model", UNSET)))
242+
not_required_model = AModelNotRequiredModel.from_dict(d.pop("not_required_model", UNSET))
235243

236244
not_required_nullable_model = None
237-
_not_required_nullable_model = d.pop("not_required_nullable_model", UNSET)
238-
if _not_required_nullable_model is not None and not isinstance(_not_required_nullable_model, Unset):
239-
not_required_nullable_model = AModelNotRequiredNullableModel.from_dict(_not_required_nullable_model)
245+
if d.pop("not_required_nullable_model", UNSET) is not None and not isinstance(
246+
d.pop("not_required_nullable_model", UNSET), Unset
247+
):
248+
if not isinstance(d.pop("not_required_nullable_model", UNSET), dict):
249+
raise ValueError(
250+
"Cannot construct model from value " + str(d.pop("not_required_nullable_model", UNSET))
251+
)
252+
not_required_nullable_model = AModelNotRequiredNullableModel.from_dict(
253+
d.pop("not_required_nullable_model", UNSET)
254+
)
240255

241256
def _parse_nullable_one_of_models(
242257
data: Union[None, Dict[str, Any]]
@@ -245,11 +260,15 @@ def _parse_nullable_one_of_models(
245260
if data is None:
246261
return data
247262
try:
263+
if not isinstance(data, dict):
264+
raise ValueError("Cannot construct model from value " + str(data))
248265
nullable_one_of_models = FreeFormModel.from_dict(data)
249266

250267
return nullable_one_of_models
251268
except: # noqa: E722
252269
pass
270+
if not isinstance(data, dict):
271+
raise ValueError("Cannot construct model from value " + str(data))
253272
nullable_one_of_models = ModelWithUnionProperty.from_dict(data)
254273

255274
return nullable_one_of_models
@@ -264,17 +283,19 @@ def _parse_not_required_one_of_models(
264283
return data
265284
try:
266285
not_required_one_of_models = UNSET
267-
_not_required_one_of_models = data
268-
if _not_required_one_of_models is not None and not isinstance(_not_required_one_of_models, Unset):
269-
not_required_one_of_models = FreeFormModel.from_dict(_not_required_one_of_models)
286+
if data is not None and not isinstance(data, Unset):
287+
if not isinstance(data, dict):
288+
raise ValueError("Cannot construct model from value " + str(data))
289+
not_required_one_of_models = FreeFormModel.from_dict(data)
270290

271291
return not_required_one_of_models
272292
except: # noqa: E722
273293
pass
274294
not_required_one_of_models = UNSET
275-
_not_required_one_of_models = data
276-
if _not_required_one_of_models is not None and not isinstance(_not_required_one_of_models, Unset):
277-
not_required_one_of_models = ModelWithUnionProperty.from_dict(_not_required_one_of_models)
295+
if data is not None and not isinstance(data, Unset):
296+
if not isinstance(data, dict):
297+
raise ValueError("Cannot construct model from value " + str(data))
298+
not_required_one_of_models = ModelWithUnionProperty.from_dict(data)
278299

279300
return not_required_one_of_models
280301

@@ -290,23 +311,19 @@ def _parse_not_required_nullable_one_of_models(
290311
return data
291312
try:
292313
not_required_nullable_one_of_models = UNSET
293-
_not_required_nullable_one_of_models = data
294-
if _not_required_nullable_one_of_models is not None and not isinstance(
295-
_not_required_nullable_one_of_models, Unset
296-
):
297-
not_required_nullable_one_of_models = FreeFormModel.from_dict(_not_required_nullable_one_of_models)
314+
if data is not None and not isinstance(data, Unset):
315+
if not isinstance(data, dict):
316+
raise ValueError("Cannot construct model from value " + str(data))
317+
not_required_nullable_one_of_models = FreeFormModel.from_dict(data)
298318

299319
return not_required_nullable_one_of_models
300320
except: # noqa: E722
301321
pass
302322
not_required_nullable_one_of_models = UNSET
303-
_not_required_nullable_one_of_models = data
304-
if _not_required_nullable_one_of_models is not None and not isinstance(
305-
_not_required_nullable_one_of_models, Unset
306-
):
307-
not_required_nullable_one_of_models = ModelWithUnionProperty.from_dict(
308-
_not_required_nullable_one_of_models
309-
)
323+
if data is not None and not isinstance(data, Unset):
324+
if not isinstance(data, dict):
325+
raise ValueError("Cannot construct model from value " + str(data))
326+
not_required_nullable_one_of_models = ModelWithUnionProperty.from_dict(data)
310327

311328
return not_required_nullable_one_of_models
312329

end_to_end_tests/golden-record-custom/custom_e2e/models/http_validation_error.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def from_dict(src_dict: Dict[str, Any]) -> "HTTPValidationError":
3434
detail = []
3535
_detail = d.pop("detail", UNSET)
3636
for detail_item_data in _detail or []:
37+
if not isinstance(detail_item_data, dict):
38+
raise ValueError("Cannot construct model from value " + str(detail_item_data))
3739
detail_item = ValidationError.from_dict(detail_item_data)
3840

3941
detail.append(detail_item)

end_to_end_tests/golden-record-custom/custom_e2e/models/model_with_additional_properties_inlined.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def from_dict(src_dict: Dict[str, Any]) -> "ModelWithAdditionalPropertiesInlined
4141

4242
additional_properties = {}
4343
for prop_name, prop_dict in d.items():
44+
if not isinstance(prop_dict, dict):
45+
raise ValueError("Cannot construct model from value " + str(prop_dict))
4446
additional_property = ModelWithAdditionalPropertiesInlinedAdditionalProperty.from_dict(prop_dict)
4547

4648
additional_properties[prop_name] = additional_property

0 commit comments

Comments
 (0)