Esempio n. 1
0
    def testRequestTimingOutEventDispatcher(self):
        """
        Test that an iq request with a defined timeout times out.
        """
        from twisted.words.xish import utility
        output = []
        xs = utility.EventDispatcher()
        xs.send = output.append

        self.iq = IQ(xs, reactor=self.reactor)
        self.iq.timeout = 60
        d = self.iq.send()
        self.assertFailure(d, xmlstream.TimeoutError)

        self.clock.pump([1, 60])
        self.assertFalse(self.reactor.getDelayedCalls())
        self.assertFalse(xs.iqDeferreds)
        return d
Esempio n. 2
0
    def test_connectionInitializedObserveItems(self):
        """
        An observer for Disco Items requests is setup on stream initialization.
        """
        xml = """<iq from='*****@*****.**' to='example.com'
                     type='get'>
                   <query xmlns='%s'/>
                 </iq>""" % NS_DISCO_ITEMS

        def handleRequest(iq):
            called.append(iq)

        called = []
        self.service.xmlstream = utility.EventDispatcher()
        self.service.handleRequest = handleRequest
        self.service.connectionInitialized()
        self.service.xmlstream.dispatch(parseXml(xml))
        self.assertEqual(1, len(called))
Esempio n. 3
0
 def setUp(self):
     self.output = []
     self.protocol = xmppim.PresenceProtocol()
     self.protocol.parent = self
     self.protocol.xmlstream = utility.EventDispatcher()
     self.protocol.connectionInitialized()
Esempio n. 4
0
 def __init__(self):
     self.source = utility.EventDispatcher()
     self.sink = utility.EventDispatcher()
     self.source.send = lambda obj: self.sink.dispatch(obj)
     self.sink.send = lambda obj: self.source.dispatch(obj)