2010-10-07 14:58:13 +00:00
|
|
|
from sleekxmpp.test import *
|
2010-07-27 01:13:09 +00:00
|
|
|
from sleekxmpp.xmlstream.jid import JID
|
|
|
|
|
2010-10-07 14:58:13 +00:00
|
|
|
|
2010-07-27 01:13:09 +00:00
|
|
|
class TestJIDClass(SleekTest):
|
2010-10-24 22:22:41 +00:00
|
|
|
|
|
|
|
"""Verify that the JID class can parse and manipulate JIDs."""
|
|
|
|
|
2010-07-27 01:13:09 +00:00
|
|
|
def testJIDfromfull(self):
|
2010-10-24 22:22:41 +00:00
|
|
|
"""Test using JID of the form 'user@server/resource/with/slashes'."""
|
|
|
|
self.check_JID(JID('user@someserver/some/resource'),
|
|
|
|
'user',
|
|
|
|
'someserver',
|
|
|
|
'some/resource',
|
|
|
|
'user@someserver',
|
|
|
|
'user@someserver/some/resource',
|
|
|
|
'user@someserver/some/resource')
|
2010-07-27 01:13:09 +00:00
|
|
|
|
|
|
|
def testJIDchange(self):
|
2010-10-24 22:22:41 +00:00
|
|
|
"""Test changing JID of the form 'user@server/resource/with/slashes'"""
|
2010-07-27 01:13:09 +00:00
|
|
|
j = JID('user1@someserver1/some1/resource1')
|
|
|
|
j.user = 'user'
|
|
|
|
j.domain = 'someserver'
|
|
|
|
j.resource = 'some/resource'
|
2010-10-24 22:22:41 +00:00
|
|
|
self.check_JID(j,
|
|
|
|
'user',
|
|
|
|
'someserver',
|
|
|
|
'some/resource',
|
|
|
|
'user@someserver',
|
|
|
|
'user@someserver/some/resource',
|
|
|
|
'user@someserver/some/resource')
|
|
|
|
|
|
|
|
def testJIDnoresource(self):
|
|
|
|
"""Test using JID of the form 'user@domain'."""
|
|
|
|
self.check_JID(JID('user@someserver'),
|
|
|
|
'user',
|
|
|
|
'someserver',
|
|
|
|
'',
|
|
|
|
'user@someserver',
|
|
|
|
'user@someserver',
|
|
|
|
'user@someserver')
|
|
|
|
|
|
|
|
def testJIDnouser(self):
|
|
|
|
"""Test JID of the form 'component.domain.tld'."""
|
|
|
|
self.check_JID(JID('component.someserver'),
|
|
|
|
'',
|
|
|
|
'component.someserver',
|
|
|
|
'',
|
|
|
|
'component.someserver',
|
|
|
|
'component.someserver',
|
|
|
|
'component.someserver')
|
2010-07-27 01:13:09 +00:00
|
|
|
|
2010-10-07 14:58:13 +00:00
|
|
|
|
2010-07-27 01:13:09 +00:00
|
|
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestJIDClass)
|