def test_array_model(self): """Test case for array_model """ from petstore_api.model import animal_farm, animal endpoint = self.api.array_model_endpoint assert endpoint.openapi_types['body'] == (animal_farm.AnimalFarm, ) assert endpoint.settings['response_type'] == (animal_farm.AnimalFarm, ) # serialization + deserialization works with patch.object(RESTClientObject, 'request') as mock_method: cat = animal.Animal(class_name="Cat", color="black") body = animal_farm.AnimalFarm([cat]) json_data = [{"className": "Cat", "color": "black"}] mock_method.return_value = self.mock_response(json_data) response = self.api.array_model(body=body) self.assert_request_called_with( mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/arraymodel', body=json_data, ) assert isinstance(response, animal_farm.AnimalFarm) assert response == body
def test_array_model(self): from petstore_api.model import animal_farm, animal # serialization + deserialization works with patch.object(RESTClientObject, 'request') as mock_request: json_data = [{"className": "Cat", "color": "black"}] mock_request.return_value = self.__response( self.__json_bytes(json_data)) cat = animal.Animal(className="Cat", color="black") body = animal_farm.AnimalFarm([cat]) api_response = self.api.array_model(body=body) self.__assert_request_called_with( mock_request, 'http://petstore.swagger.io:80/v2/fake/refs/arraymodel', body=self.__json_bytes(json_data)) assert isinstance(api_response.body, animal_farm.AnimalFarm) assert api_response.body == body