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)
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])
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)
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)