def test_onVersion(self): """ Test response to incoming version request. """ self.stub = XmlStreamStub() self.protocol = generic.VersionHandler('Test', '0.1.0') self.protocol.xmlstream = self.stub.xmlstream self.protocol.send = self.stub.xmlstream.send self.protocol.connectionInitialized() iq = domish.Element((None, 'iq')) iq['from'] = '[email protected]/Home' iq['to'] = 'example.org' iq['type'] = 'get' iq.addElement((NS_VERSION, 'query')) self.stub.send(iq) response = self.stub.output[-1] self.assertEquals('[email protected]/Home', response['to']) self.assertEquals('example.org', response['from']) self.assertEquals('result', response['type']) self.assertEquals(NS_VERSION, response.query.uri) elements = list( domish.generateElementsQNamed(response.query.children, 'name', NS_VERSION)) self.assertEquals(1, len(elements)) self.assertEquals('Test', unicode(elements[0])) elements = list( domish.generateElementsQNamed(response.query.children, 'version', NS_VERSION)) self.assertEquals(1, len(elements)) self.assertEquals('0.1.0', unicode(elements[0]))
# initialize database database.init(conf.mysqlHost, conf.mysqlUsername, conf.mysqlPassword, conf.mysqlDatabase) # start xmpp component xmpp = Component(conf.jabberHost, conf.jabberPort, conf.jabberComponentName, conf.jabberPassword) xmpp.logTraffic = False handler = XMPPComponent() handler.setHandlerParent(xmpp) # fallback handling generic.FallbackHandler().setHandlerParent(xmpp) # version handling generic.VersionHandler("SMS.de Gateway", "1.0").setHandlerParent(xmpp) # allow disco handling disco.DiscoHandler().setHandlerParent(xmpp) DiscoResponder().setHandlerParent(xmpp) # add handler for gateway requests GatewayHandler().setHandlerParent(xmpp) # add handler for vcards VCardHandler().setHandlerParent(xmpp) # add handler for registering RegisterHandler().setHandlerParent(xmpp) # PresenceHandler
def setUp(self): self.protocol = generic.VersionHandler('Test', '0.1.0')