コード例 #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
コード例 #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)
コード例 #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
コード例 #4
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'
コード例 #5
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'
コード例 #6
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')