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)
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)
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
def test_interface(self): """ L{xmlstream.XMPPHandler} implements L{ijabber.IXMPPHandler}. """ verifyObject(ijabber.IXMPPHandler, subprotocols.XMPPHandler())