def test_basic(self): """ getServiceAndNode parses an XMPP URI with node parameter. """ uri = b'xmpp:pubsub.example.org?;node=test' service, nodeIdentifier = gateway.getServiceAndNode(uri) self.assertEqual(JID(u'pubsub.example.org'), service) self.assertEqual(u'test', nodeIdentifier)
def cb(response): xmppURI = response['uri'] jid, nodeIdentifier = gateway.getServiceAndNode(xmppURI) rootNode = gateway.getXMPPURI(jid, '') d = self.client.subscribe(rootNode) d.addCallback(lambda _: xmppURI) return d
def test_nodeAbsent(self): """ If the node parameter is missing, the nodeIdentifier is empty. """ uri = b'xmpp:pubsub.example.org?' service, nodeIdentifier = gateway.getServiceAndNode(uri) self.assertEqual(JID(u'pubsub.example.org'), service) self.assertEqual(u'', nodeIdentifier)
def test_queryEmpty(self): """ If there is no query component, the nodeIdentifier is empty. """ uri = b'xmpp:pubsub.example.org' service, nodeIdentifier = gateway.getServiceAndNode(uri) self.assertEqual(JID(u'pubsub.example.org'), service) self.assertEqual(u'', nodeIdentifier)
def cb(response): xmppURI = response['uri'] jid, nodeIdentifier = gateway.getServiceAndNode(xmppURI) rootNode = gateway.getXMPPURI(jid, '') d = self.client.subscribe(rootNode) d.addCallback(lambda _: self.addCleanup(clean, rootNode)) d.addCallback(lambda _: xmppURI) return d
def gotNodes(nodeIdentifiers, uri): service, nodeIdentifier = gateway.getServiceAndNode(uri) self.assertIn(nodeIdentifier, nodeIdentifiers)