def test_number_with_validations(self): """Test case for number_with_validations """ from petstore_api.model import number_with_validations endpoint = self.api.number_with_validations assert endpoint.openapi_types['body'] == ( number_with_validations.NumberWithValidations, ) assert endpoint.settings['response_type'] == ( number_with_validations.NumberWithValidations, ) # serialization + deserialization works with patch.object(RESTClientObject, 'request') as mock_method: value = 10.0 body = number_with_validations.NumberWithValidations(value) mock_method.return_value = self.mock_response(value) response = endpoint(body=body) self.assert_request_called_with( mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/number', body=value) assert isinstance(response, number_with_validations.NumberWithValidations) assert response.value == value
def test_composed_one_of_number_with_validations(self): """Test case for composed_one_of_number_with_validations """ from petstore_api.model import animal, composed_one_of_number_with_validations, number_with_validations endpoint = self.api.composed_one_of_number_with_validations_endpoint assert endpoint.openapi_types[ 'composed_one_of_number_with_validations'] == ( composed_one_of_number_with_validations. ComposedOneOfNumberWithValidations, ) assert endpoint.settings['response_type'] == ( composed_one_of_number_with_validations. ComposedOneOfNumberWithValidations, ) # serialization + deserialization works num_with_validations = number_with_validations.NumberWithValidations( 10.0) cat_in_composed = composed_one_of_number_with_validations.ComposedOneOfNumberWithValidations( class_name="Cat", color="black") import datetime date = datetime.date(1970, 1, 1) body_value_simple = [ (num_with_validations, 10.0), (cat_in_composed, { "className": "Cat", "color": "black" }), (None, None), (date, '1970-01-01'), ] for (body, value_simple) in body_value_simple: with patch.object(RESTClientObject, 'request') as mock_method: mock_method.return_value = self.mock_response(value_simple) response = self.api.composed_one_of_number_with_validations( composed_one_of_number_with_validations=body) self.assert_request_called_with( mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/composed_one_of_number_with_validations', body=value_simple, ) assert isinstance(response, body.__class__) assert response == body
def test_number_with_validations(self): from petstore_api.model import number_with_validations # serialization + deserialization works with patch.object(RESTClientObject, 'request') as mock_request: value = 10.0 body = number_with_validations.NumberWithValidations(value) mock_request.return_value = self.__response( self.__json_bytes(value)) api_response = self.api.number_with_validations(body=body) self.__assert_request_called_with( mock_request, 'http://petstore.swagger.io:80/v2/fake/refs/number', body=self.__json_bytes(value)) assert isinstance(api_response.body, number_with_validations.NumberWithValidations) assert api_response.body == value