예제 #1
0
    def test_addAndRemoveBootstrap(self):
        """
        Test addition and removal of a bootstrap event handler.
        """
        def cb(self):
            pass

        f = XmlStreamFactoryMixin(None, test=None)

        f.addBootstrap('//event/myevent', cb)
        self.assertIn(('//event/myevent', cb), f.bootstraps)

        f.removeBootstrap('//event/myevent', cb)
        self.assertNotIn(('//event/myevent', cb), f.bootstraps)
예제 #2
0
    def test_buildProtocol(self):
        """
        Test building of protocol.

        Arguments passed to Factory should be passed to protocol on
        instantiation. Bootstrap observers should be setup.
        """
        d = defer.Deferred()

        f = XmlStreamFactoryMixin(None, test=None)
        f.protocol = DummyProtocol
        f.addBootstrap('//event/myevent', d.callback)
        xs = f.buildProtocol(None)

        self.assertEquals(f, xs.factory)
        self.assertEquals((None,), xs.args)
        self.assertEquals({'test': None}, xs.kwargs)
        xs.dispatch(None, '//event/myevent')
        return d