summaryrefslogtreecommitdiff
path: root/tests/test_jid.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-10-24 18:22:41 -0400
committerLance Stout <lancestout@gmail.com>2010-10-24 18:22:41 -0400
commit9e3d506651e446992a31f66f11b64831f42fddbf (patch)
treea140979ac7c609b371f40130a46251d9203a21ab /tests/test_jid.py
parent2f3ff37a2470c2b1c0f3f20daada1a2fd3d19535 (diff)
downloadslixmpp-9e3d506651e446992a31f66f11b64831f42fddbf.tar.gz
slixmpp-9e3d506651e446992a31f66f11b64831f42fddbf.tar.bz2
slixmpp-9e3d506651e446992a31f66f11b64831f42fddbf.tar.xz
slixmpp-9e3d506651e446992a31f66f11b64831f42fddbf.zip
Fixed resource bug in JIDs.
JIDs without resources will return '' instead of the bare JID. Cleaned up JID tests, and added check_JID to SleekTest.
Diffstat (limited to 'tests/test_jid.py')
-rw-r--r--tests/test_jid.py52
1 files changed, 39 insertions, 13 deletions
diff --git a/tests/test_jid.py b/tests/test_jid.py
index 45047313..38dc6ed5 100644
--- a/tests/test_jid.py
+++ b/tests/test_jid.py
@@ -3,26 +3,52 @@ from sleekxmpp.xmlstream.jid import JID
class TestJIDClass(SleekTest):
+
+ """Verify that the JID class can parse and manipulate JIDs."""
+
def testJIDfromfull(self):
- j = JID('user@someserver/some/resource')
- self.assertEqual(j.user, 'user', "User does not match")
- self.assertEqual(j.domain, 'someserver', "Domain does not match")
- self.assertEqual(j.resource, 'some/resource', "Resource does not match")
- self.assertEqual(j.bare, 'user@someserver', "Bare does not match")
- self.assertEqual(j.full, 'user@someserver/some/resource', "Full does not match")
- self.assertEqual(str(j), 'user@someserver/some/resource', "String does not match")
+ """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.assertEqual(j.user, 'user', "User does not match")
- self.assertEqual(j.domain, 'someserver', "Domain does not match")
- self.assertEqual(j.resource, 'some/resource', "Resource does not match")
- self.assertEqual(j.bare, 'user@someserver', "Bare does not match")
- self.assertEqual(j.full, 'user@someserver/some/resource', "Full does not match")
- self.assertEqual(str(j), 'user@someserver/some/resource', "String does not match")
+ 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)