Skip to content
Merged
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 openapi_python_client/openapi_parser/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def constructor(self) -> str:
def response_from_dict(*, status_code: int, data: Dict[str, Any]) -> Response:
""" Generate a Response from the OpenAPI dictionary representation of it """
if "content" not in data:
raise ParseError(data)
return Response(status_code=status_code)

content = data["content"]
if "application/json" in content:
Expand Down
11 changes: 8 additions & 3 deletions tests/test_openapi_parser/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,16 @@ def test_constructor(self):


class TestResponseFromDict:
def test_response_from_dict_no_content(self):
def test_response_from_dict_no_content(self, mocker):
from openapi_python_client.openapi_parser.responses import response_from_dict

with pytest.raises(ValueError):
response_from_dict(status_code=200, data={})
Response = mocker.patch(f"{MODULE_NAME}.Response")

status_code = mocker.MagicMock(autospec=int)
response = response_from_dict(status_code=status_code, data={})

Response.assert_called_once_with(status_code=status_code)
assert response == Response()

def test_response_from_dict_unsupported_content_type(self):
from openapi_python_client.openapi_parser.responses import response_from_dict
Expand Down