コード例 #1
0
 def test_connectionLost(self):
     """
     Test that connectionLost forgets the XML stream.
     """
     handler = subprotocols.XMPPHandler()
     xs = xmlstream.XmlStream(xmlstream.Authenticator())
     handler.makeConnection(xs)
     handler.connectionLost(Exception())
     self.assertIdentical(None, handler.xmlstream)
コード例 #2
0
    def test_send(self):
        """
        Test that data is passed on for sending by the stream manager.
        """
        class DummyStreamManager(object):
            def __init__(self):
                self.outlist = []

            def send(self, data):
                self.outlist.append(data)

        handler = subprotocols.XMPPHandler()
        handler.parent = DummyStreamManager()
        handler.send('<presence/>')
        self.assertEquals(['<presence/>'], handler.parent.outlist)
コード例 #3
0
    def test_request(self):
        """
        A request is passed up to the stream manager.
        """
        class DummyStreamManager(object):
            def __init__(self):
                self.requests = []

            def request(self, request):
                self.requests.append(request)
                return defer.succeed(None)

        handler = subprotocols.XMPPHandler()
        handler.parent = DummyStreamManager()
        request = IQGetStanza()
        d = handler.request(request)
        self.assertEquals(1, len(handler.parent.requests))
        self.assertIdentical(request, handler.parent.requests[-1])
        return d
コード例 #4
0
 def test_interface(self):
     """
     L{xmlstream.XMPPHandler} implements L{ijabber.IXMPPHandler}.
     """
     verifyObject(ijabber.IXMPPHandler, subprotocols.XMPPHandler())