@@ -181,3 +181,47 @@ def test_from_dict(self, mocker):
181181 relative_imports = {import_string_from_reference ()},
182182 description = in_data ["description" ],
183183 )
184+
185+
186+ class TestEndpoint :
187+ def test_parse_request_form_body (self , mocker ):
188+ ref = mocker .MagicMock ()
189+ body = {"content" : {"application/x-www-form-urlencoded" : {"schema" : {"$ref" : ref }}}}
190+ Reference = mocker .patch (f"{ MODULE_NAME } .Reference" )
191+
192+ from openapi_python_client .openapi_parser .openapi import Endpoint
193+
194+ result = Endpoint .parse_request_form_body (body )
195+
196+ Reference .assert_called_once_with (ref )
197+ assert result == Reference ()
198+
199+ def test_parse_request_form_body_no_data (self ):
200+ body = {"content" : {}}
201+
202+ from openapi_python_client .openapi_parser .openapi import Endpoint
203+
204+ result = Endpoint .parse_request_form_body (body )
205+
206+ assert result is None
207+
208+ def test_parse_request_json_body (self , mocker ):
209+ schema = mocker .MagicMock ()
210+ body = {"content" : {"application/json" : {"schema" : schema }}}
211+ property_from_dict = mocker .patch (f"{ MODULE_NAME } .property_from_dict" )
212+
213+ from openapi_python_client .openapi_parser .openapi import Endpoint
214+
215+ result = Endpoint .parse_request_json_body (body )
216+
217+ property_from_dict .assert_called_once_with ("json_body" , required = True , data = schema )
218+ assert result == property_from_dict ()
219+
220+ def test_parse_request_json_body_no_data (self ):
221+ body = {"content" : {}}
222+
223+ from openapi_python_client .openapi_parser .openapi import Endpoint
224+
225+ result = Endpoint .parse_request_json_body (body )
226+
227+ assert result is None
0 commit comments