summaryrefslogtreecommitdiff
path: root/tests/test_jid.py
diff options
context:
space:
mode:
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)