Here are the examples of the python api twisted.words.protocols.jabber.jid.JID taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
39 Examples
3
View Complete Implementation : test_jabberclient.py
Copyright MIT License
Author : adde88
Copyright MIT License
Author : adde88
def testFailure(self):
"""
Test basic operations.
Set up a stream, and act as if resource binding fails.
"""
def cb(result):
self.astertEquals(jid.JID('[email protected]/resource'),
self.authenticator.jid)
d = self.init.start()
id = self.output[0]['id']
self.xmlstream.dataReceived("<iq type='error' id='%s'/>" % id)
self.astertFailure(d, error.StanzaError)
return d
3
View Complete Implementation : component.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def route(self, stanza):
"""
Route a stanza.
@param stanza: The stanza to be routed.
@type stanza: L{domish.Element}.
"""
destination = JID(stanza['to'])
log.msg("Routing to %s: %r" % (destination.full(), stanza.toXml()))
if destination.host in self.routes:
self.routes[destination.host].send(stanza)
else:
self.routes[None].send(stanza)
3
View Complete Implementation : test_jabberclient.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def testBasic(self):
"""
Set up a stream, and act as if resource binding succeeds.
"""
def onBind(iq):
response = xmlstream.toResponse(iq, 'result')
response.addElement((NS_BIND, 'bind'))
response.bind.addElement('jid',
content=u'[email protected]/other resource')
self.pipe.source.send(response)
def cb(result):
self.astertEqual(jid.JID('[email protected]/other resource'),
self.authenticator.jid)
d1 = self.waitFor(IQ_BIND_SET, onBind)
d2 = self.init.start()
d2.addCallback(cb)
return defer.gatherResults([d1, d2])
3
View Complete Implementation : test_jabbercomponent.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def setUp(self):
self.router = component.Router()
self.factory = component.XMPPComponentServerFactory(self.router,
'secret')
self.xmlstream = self.factory.buildProtocol(None)
self.xmlstream.thisEnsaty = JID('component.example.org')
3
View Complete Implementation : test_jabberjid.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_attributes(self):
"""
Test that the attributes correspond with the JID parts.
"""
j = jid.JID("user@host/resource")
self.astertEqual(j.user, "user")
self.astertEqual(j.host, "host")
self.astertEqual(j.resource, "resource")
3
View Complete Implementation : test_jabberjid.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_userhost(self):
"""
Test the extraction of the bare JID.
"""
j = jid.JID("user@host/resource")
self.astertEqual("user@host", j.userhost())
3
View Complete Implementation : test_jabberjid.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_userhostOnlyHost(self):
"""
Test the extraction of the bare JID of the full form host/resource.
"""
j = jid.JID("host/resource")
self.astertEqual("host", j.userhost())
3
View Complete Implementation : test_jabberjid.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_userhostJID(self):
"""
Test getting a JID object of the bare JID.
"""
j1 = jid.JID("user@host/resource")
j2 = jid.internJID("user@host")
self.astertIdentical(j2, j1.userhostJID())
3
View Complete Implementation : test_jabberjid.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_userhostJIDNoResource(self):
"""
Test getting a JID object of the bare JID when there was no resource.
"""
j = jid.JID("user@host")
self.astertIdentical(j, j.userhostJID())
3
View Complete Implementation : test_jabberjid.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_fullHost(self):
"""
Test giving a string representation of the JID with only a host part.
"""
j = jid.JID(tuple=(None, 'host', None))
self.astertEqual('host', j.full())