def testMammal(self): """Test Mammal""" # tests that we can make a BasquePig by traveling through descendant discriminator in Pig model = Mammal(class_name="BasquePig") from petstore_api.model import basque_pig assert isinstance(model, basque_pig.BasquePig)
def testMammal(self): """Test Mammal""" # tests that we can make a BasquePig by traveling through discriminator in Pig m = Mammal(className="BasquePig") from petstore_api.model import pig from petstore_api.model import basque_pig assert isinstance(m, Mammal) assert isinstance(m, basque_pig.BasquePig) assert isinstance(m, pig.Pig) # can make a Whale m = Mammal(className="whale") from petstore_api.model import whale assert isinstance(m, whale.Whale) # can use the enum value m = Mammal(className=whale.Whale.className.WHALE) assert isinstance(m, whale.Whale) from petstore_api.model import zebra m = Mammal(className='zebra') assert isinstance(m, zebra.Zebra)
def test_mammal(self): # serialization + deserialization works from petstore_api.model.mammal import Mammal with patch.object(RESTClientObject, 'request') as mock_request: body = Mammal(className="BasquePig") value_simple = dict(className='BasquePig') mock_request.return_value = self.__response( self.__json_bytes(value_simple)) api_response = self.api.mammal(body=body) self.__assert_request_called_with( mock_request, 'http://petstore.swagger.io:80/v2/fake/refs/mammal', body=self.__json_bytes(value_simple)) assert isinstance(api_response.body, Mammal) assert api_response.body == value_simple
def testDeepCopyOneOf(self): """test deepcopy""" obj = deepcopy(Mammal(class_name="whale")) assert id(deepcopy(obj)) != id(obj) assert deepcopy(obj) == obj