def test_listen(self): def method(): pass mam = ModelAttributeMapper(Model.System.Model.use('name'), 'set') mam.listen(method) assert method.is_an_sqlalchemy_event_listener assert method.sqlalchemy_listener is mam
def test_listen(self): def method(): pass mam = ModelAttributeMapper(Model.System.Model.use('name'), 'set') mam.listen(method) self.assertTrue(method.is_an_sqlalchemy_event_listener) self.assertEqual(method.sqlalchemy_listener, mam)
def test_get_attribute_mapper(self): registry = self.init_registry(None) mam = ModelAttributeMapper(Model.System.Model.use('name'), 'set') # We can't compare that the column are the same, because is the case # of the call are in the class attribute (no instance) SQLAlchemy # Wrap the result for each call, then each call return a différent # object, but it is not an error getted = str(mam.mapper(registry, None) == 'test') wanted = str(registry.System.Model.name == 'test') assert getted == wanted
def test_get_mapper(self): registry = self.init_registry(None) mam = ModelAttributeMapper(Model.System.Model.use('name'), 'set') # We can't compare that the column are the same, because is the case # of the call are in the class attribute (no instance) SQLAlchemy # Wrap the result for each call, then each call return a différent # object, but it is not an error self.assertEqual( str(mam.mapper(registry, None) == 'test'), str(registry.System.Model.name == 'test'))
def test_by_registry_name(self): mam = ModelAttributeMapper('Model.System.Model=>name', 'event') assert isinstance(mam.attribute, ModelAttribute) assert mam.attribute.model_name == 'Model.System.Model'
def test_by_declaration(self): mam = ModelAttributeMapper(Model.System.Model.use('name'), 'event') assert isinstance(mam.attribute, ModelAttribute) assert mam.attribute.model_name == 'Model.System.Model'
def test_capable_by_registry_name(self): assert ModelAttributeMapper.capable('Model.System.Model=>name')
def test_capable_by_declaration(self): assert ModelAttributeMapper.capable(Model.System.Model.use('name'))
def test_not_capable(self): assert not (ModelAttributeMapper.capable(None))
def test_not_str_capable(self): assert not (ModelAttributeMapper.capable('Model.System.Model'))
def test_by_registry_name(self): mam = ModelAttributeMapper('Model.System.Model=>name', 'event') self.assertTrue(isinstance(mam.attribute, ModelAttribute)) self.assertTrue(mam.attribute.model_name, 'Model.System.Model')
def test_capable_by_registry_name(self): self.assertTrue(ModelAttributeMapper.capable( 'Model.System.Model=>name'))
def test_capable_by_declaration(self): self.assertTrue(ModelAttributeMapper.capable( Model.System.Model.use('name')))
def test_not_capable(self): self.assertFalse(ModelAttributeMapper.capable(None))
def test_not_str_capable(self): self.assertFalse(ModelAttributeMapper.capable('Model.System.Model'))