def test_register_callback(self): command_class = CTICommandClass(self.class_name, None, None) command = command_class.from_dict({'class': 'callback_test'}) self.assertEqual(command.callbacks_with_params(), []) function = Mock() command_class.register_callback_params(function) command = command_class.from_dict({'class': 'callback_test'}) self.assertEqual(len(command.callbacks_with_params()), 1)
def test_register_callback(self): command_class = CTICommandClass(self.class_name, None, None) command = command_class.from_dict({'class': 'callback_test'}) self.assertEqual(command.callbacks_with_params(), []) function = Mock() command_class.register_callback_params(function) command = command_class.from_dict({'class': 'callback_test'}) self.assertEqual(len(command.callbacks_with_params()), 1)
def test_deregister_callback_wrapped(self): command_class = CTICommandClass(self.class_name, None, None) command = command_class.from_dict({'class': 'callback_test'}) function_1 = lambda: None function_2 = lambda: None command_class.register_callback_params(function_1) command_class.register_callback_params(function_2) command_class.deregister_callback(command.callbacks_with_params()[0][0]) callbacks = command.callbacks_with_params() self.assertEqual(len(callbacks), 1) self.assertEqual(weak_method.WeakCallable(function_2), callbacks[0][0])