Exemple #1
0
 def test_unknown_callbacks_are_ignored(self):
     """
     Checks that unkown callbacks are silently ignored.
     """
     callbacks = {'foo': Mock()}
     data = message.encode('bar')
     message.handle_message(data, callbacks)
Exemple #2
0
    def test_args_forwarded(self):
        callbacks = {'foo': Mock()}
        data = message.encode('foo', [1, 2, 3])

        message.handle_message(data, callbacks)
        callbacks['foo'].assert_any_call([1, 2, 3])
Exemple #3
0
 def test_default_callback(self):
     callbacks = {'foo': Mock()}
     data = message.encode('bar', 42)
     default_cb = Mock()
     message.handle_message(data, callbacks, default_callback=default_cb)
     default_cb.assert_called_once_with('bar', 42)
Exemple #4
0
    def test_correct_callback_called(self):
        callbacks = {'foo': Mock(), 'bar': Mock()}

        data = message.encode('bar')
        message.handle_message(data, callbacks)
        callbacks['bar'].assert_any_call(None)