mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-24 03:00:15 +00:00
9e3d506651
JIDs without resources will return '' instead of the bare JID. Cleaned up JID tests, and added check_JID to SleekTest.
54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
from sleekxmpp.test import *
|
|
from sleekxmpp.xmlstream.jid import JID
|
|
|
|
|
|
class TestJIDClass(SleekTest):
|
|
|
|
"""Verify that the JID class can parse and manipulate JIDs."""
|
|
|
|
def testJIDfromfull(self):
|
|
"""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')
|
|
|
|
def testJIDchange(self):
|
|
"""Test changing JID of the form 'user@server/resource/with/slashes'"""
|
|
j = JID('user1@someserver1/some1/resource1')
|
|
j.user = 'user'
|
|
j.domain = 'someserver'
|
|
j.resource = 'some/resource'
|
|
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')
|
|
|
|
|
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestJIDClass)
|