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

        with pytest.raises(ValueError):
            response_from_dict(status_code=200,
                               data={"content": {
                                   "not/real": {}
                               }})
    def test_response_from_dict_unsupported_type(self):
        from openapi_python_client.openapi_parser.responses import response_from_dict

        with pytest.raises(ValueError):
            response_from_dict(status_code=200,
                               data={
                                   "content": {
                                       "application/json": {
                                           "schema": {
                                               "type": "blah"
                                           }
                                       }
                                   }
                               })
    def test_response_from_dict_array(self, mocker):
        ref = mocker.MagicMock()
        status_code = mocker.MagicMock(autospec=int)
        data = {
            "content": {
                "application/json": {
                    "schema": {
                        "type": "array",
                        "items": {
                            "$ref": ref
                        }
                    }
                }
            }
        }
        from_ref = mocker.patch(f"{MODULE_NAME}.Reference.from_ref")
        ListRefResponse = mocker.patch(f"{MODULE_NAME}.ListRefResponse")
        from openapi_python_client.openapi_parser.responses import response_from_dict

        response = response_from_dict(status_code=status_code, data=data)

        from_ref.assert_called_once_with(ref)
        ListRefResponse.assert_called_once_with(status_code=status_code,
                                                reference=from_ref())
        assert response == ListRefResponse()
    def test_response_from_dict_no_content(self, mocker):
        from openapi_python_client.openapi_parser.responses import response_from_dict
        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_empty(self, mocker):
        status_code = mocker.MagicMock(autospec=int)
        data = {"content": {"application/json": {"schema": {}}}}
        Response = mocker.patch(f"{MODULE_NAME}.Response")
        from openapi_python_client.openapi_parser.responses import response_from_dict

        response = response_from_dict(status_code=status_code, data=data)

        Response.assert_called_once_with(status_code=status_code)
        assert response == Response()
    def test_response_from_dict_basic(self, mocker):
        status_code = mocker.MagicMock(autospec=int)
        data = {"content": {"text/html": {"schema": {"type": "string"}}}}
        BasicResponse = mocker.patch(f"{MODULE_NAME}.BasicResponse")
        from openapi_python_client.openapi_parser.responses import response_from_dict

        response = response_from_dict(status_code=status_code, data=data)

        BasicResponse.assert_called_once_with(status_code=status_code,
                                              openapi_type="string")
        assert response == BasicResponse.return_value