class BootstrapMixinTest(unittest.TestCase): """ Tests for L{BootstrapMixin}. @ivar factory: Instance of the factory or mixin under test. """ def setUp(self): self.factory = BootstrapMixin() def test_installBootstraps(self): """ Dispatching an event should fire registered bootstrap observers. """ called = [] def cb(data): called.append(data) dispatcher = DummyProtocol() self.factory.addBootstrap('//event/myevent', cb) self.factory.installBootstraps(dispatcher) dispatcher.dispatch(None, '//event/myevent') self.assertEquals(1, len(called)) def test_addAndRemoveBootstrap(self): """ Test addition and removal of a bootstrap event handler. """ called = [] def cb(data): called.append(data) self.factory.addBootstrap('//event/myevent', cb) self.factory.removeBootstrap('//event/myevent', cb) dispatcher = DummyProtocol() self.factory.installBootstraps(dispatcher) dispatcher.dispatch(None, '//event/myevent') self.assertFalse(called)
def setUp(self): self.factory = BootstrapMixin()