Example #1
0
    def test_registers_callback_by_type(self):
        """should create key from type pointing to list containing callback"""
        m = CallbackManager()
        cb = callbacks.before_load(lambda: 1)

        m.register(cb)
        self.assertEqual(m.callbacks[callbacks.before_load], [cb])
Example #2
0
    def test_registers_callback_by_type(self):
        """should create key from type pointing to list containing callback"""
        m = CallbackManager()
        cb = callbacks.before_load(lambda: 1)

        m.register(cb)
        self.assertEqual(
                m.callbacks[callbacks.before_load],
                [cb] )
Example #3
0
    def test_trigger_callbacks_of_specified_type(self):
        """should trigger each registered callback"""
        m = CallbackManager()
        i = []
        def call(arg): arg.append(1)
        cb = callbacks.before_save(call)

        m.register(cb)
        m.register(cb)

        m.trigger(callbacks.before_save, i)

        self.assertEqual(len(i), 2)
Example #4
0
    def test_trigger_callbacks_of_specified_type(self):
        """should trigger each registered callback"""
        m = CallbackManager()
        i = []

        def call(arg):
            arg.append(1)

        cb = callbacks.before_save(call)

        m.register(cb)
        m.register(cb)

        m.trigger(callbacks.before_save, i)

        self.assertEqual(len(i), 2)