def test_registering_functions(self):
        # Tests that the abilities were set on the GearmanWorker AND the GearmanWorkerCommandHandler
        # Does NOT test that commands were actually sent out as that is tested in GearmanWorkerCommandHandlerInterfaceTest.test_set_abilities
        def fake_callback_one(worker_command_handler, current_job):
            pass

        def fake_callback_two(worker_command_handler, current_job):
            pass

        # Register a single callback
        self.connection_manager.register_task('fake_callback_one', fake_callback_one)
        self.failUnless('fake_callback_one' in self.connection_manager.worker_abilities)
        self.failIf('fake_callback_two' in self.connection_manager.worker_abilities)
        self.assertEqual(self.connection_manager.worker_abilities['fake_callback_one'], fake_callback_one)
        self.assertEqual(self.command_handler._handler_abilities, ['fake_callback_one'])

        # Register another callback and make sure the command_handler sees the same functions
        self.connection_manager.register_task('fake_callback_two', fake_callback_two)
        self.failUnless(self.connection_manager.worker_abilities in 'fake_callback_one')
        self.failUnless('fake_callback_two' in self.connection_manager.worker_abilities)
        self.assertEqual(self.connection_manager.worker_abilities['fake_callback_one'], fake_callback_one)
        self.assertEqual(self.connection_manager.worker_abilities['fake_callback_two'], fake_callback_two)
        self.assertEqual(self.command_handler._handler_abilities, ['fake_callback_one', 'fake_callback_two'])

        # Unregister a callback and make sure the command_handler sees the same functions
        self.connection_manager.unregister_task('fake_callback_one')
        self.failIf('fake_callback_one' in self.connection_manager.worker_abilities)
        self.failUnless('fake_callback_two' in self.connection_manager.worker_abilities)
        self.assertEqual(self.connection_manager.worker_abilities['fake_callback_two'], fake_callback_two)
        self.assertEqual(self.command_handler._handler_abilities, ['fake_callback_two'])
dataset/ETHPy150Open YelpArchive/python-gearman/tests/worker_tests.py/WorkerTest.test_registering_functions/swapped operands of `in`