@@ -167,10 +167,45 @@ def test_object_model_with_ref_props(self):
167167 """Test case for object_model_with_ref_props
168168
169169 """
170- from petstore_api .model import object_model_with_ref_props
170+ from petstore_api .model .object_model_with_ref_props import ObjectModelWithRefProps
171+ from petstore_api .model .number_with_validations import NumberWithValidations
171172 endpoint = self .api .object_model_with_ref_props
172- assert endpoint .openapi_types ['body' ] == (object_model_with_ref_props .ObjectModelWithRefProps ,)
173- assert endpoint .settings ['response_type' ] == (object_model_with_ref_props .ObjectModelWithRefProps ,)
173+ assert endpoint .openapi_types ['body' ] == (ObjectModelWithRefProps ,)
174+ assert endpoint .settings ['response_type' ] == (ObjectModelWithRefProps ,)
175+
176+ json_payloads = [
177+ {}, # only required + no optional properties works
178+ { # optional properties works
179+ "my_number" : 11.0 ,
180+ "my_string" : 'a' ,
181+ "my_boolean" : True ,
182+ }
183+ ]
184+ # instantiation works
185+ expected_models = [
186+ ObjectModelWithRefProps (),
187+ ObjectModelWithRefProps (
188+ my_number = NumberWithValidations (11.0 ),
189+ my_string = 'a' ,
190+ my_boolean = True
191+ )
192+ ]
193+
194+ pairs = zip (json_payloads , expected_models )
195+ # serialization + deserialization works
196+ for (json_payload , expected_model ) in pairs :
197+ with patch .object (RESTClientObject , 'request' ) as mock_method :
198+ mock_method .return_value = self .mock_response (json_payload )
199+
200+ response = endpoint (body = expected_model )
201+ self .assert_request_called_with (
202+ mock_method ,
203+ 'http://petstore.swagger.io:80/v2/fake/refs/object_model_with_ref_props' ,
204+ json_payload
205+ )
206+
207+ assert isinstance (response , expected_model .__class__ )
208+ assert response == expected_model
174209
175210 def test_composed_one_of_number_with_validations (self ):
176211 """Test case for composed_one_of_number_with_validations
0 commit comments