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

        f = xmlstream.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)
Beispiel #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 = xmlstream.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
 def setUp(self):
     self.factory = xmlstream.XmlStreamFactoryMixin(None, test=None)
     self.factory.protocol = DummyProtocol