Example #1
0
    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
Example #2
0
    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)
Example #3
0
 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
Example #4
0
 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'))
Example #5
0
 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'
Example #6
0
 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'
Example #7
0
 def test_capable_by_registry_name(self):
     assert ModelAttributeMapper.capable('Model.System.Model=>name')
Example #8
0
 def test_capable_by_declaration(self):
     assert ModelAttributeMapper.capable(Model.System.Model.use('name'))
Example #9
0
 def test_not_capable(self):
     assert not (ModelAttributeMapper.capable(None))
Example #10
0
 def test_not_str_capable(self):
     assert not (ModelAttributeMapper.capable('Model.System.Model'))
Example #11
0
 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')
Example #12
0
 def test_capable_by_registry_name(self):
     self.assertTrue(ModelAttributeMapper.capable(
         'Model.System.Model=>name'))
Example #13
0
 def test_capable_by_declaration(self):
     self.assertTrue(ModelAttributeMapper.capable(
         Model.System.Model.use('name')))
Example #14
0
 def test_not_capable(self):
     self.assertFalse(ModelAttributeMapper.capable(None))
Example #15
0
 def test_not_str_capable(self):
     self.assertFalse(ModelAttributeMapper.capable('Model.System.Model'))