Skip to content

Commit 1f5d597

Browse files
committed
test: Add coverage for missing branch
1 parent 9053cbc commit 1f5d597

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/test_parser/test_openapi.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,35 @@ def test_add_body_bad_json_data(self, mocker):
311311
other_schemas,
312312
)
313313

314+
def test_add_body_bad_form_data(self, enum_property_factory):
315+
from openapi_python_client.parser.openapi import Endpoint, Schemas
316+
317+
schemas = Schemas(
318+
errors=[ParseError(detail="existing error")],
319+
)
320+
endpoint = self.make_endpoint()
321+
bad_schema = oai.Schema.construct(type=oai.DataType.ARRAY)
322+
323+
result = Endpoint._add_body(
324+
endpoint=endpoint,
325+
data=oai.Operation.construct(
326+
requestBody=oai.RequestBody.construct(
327+
content={"application/x-www-form-urlencoded": oai.MediaType.construct(media_type_schema=bad_schema)}
328+
)
329+
),
330+
schemas=schemas,
331+
config=Config(),
332+
)
333+
334+
assert result == (
335+
ParseError(
336+
detail="type array must have items defined",
337+
header="Cannot parse form body of endpoint name",
338+
data=bad_schema,
339+
),
340+
schemas,
341+
)
342+
314343
def test_add_body_bad_multipart_data(self, mocker):
315344
from openapi_python_client.parser.openapi import Endpoint, Schemas
316345

0 commit comments

Comments
 (0)