summaryrefslogtreecommitdiff
path: root/sleekxmpp
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 /sleekxmpp
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 'sleekxmpp')
-rw-r--r--sleekxmpp/test/sleektest.py35
-rw-r--r--sleekxmpp/xmlstream/jid.py2
2 files changed, 36 insertions, 1 deletions
diff --git a/sleekxmpp/test/sleektest.py b/sleekxmpp/test/sleektest.py
index ce105629..2901e59b 100644
--- a/sleekxmpp/test/sleektest.py
+++ b/sleekxmpp/test/sleektest.py
@@ -103,6 +103,41 @@ class SleekTest(unittest.TestCase):
"""
return Presence(None, *args, **kwargs)
+
+
+ def check_JID(self, jid, user=None, domain=None, resource=None,
+ bare=None, full=None, string=None):
+ """
+ Verify the components of a JID.
+
+ Arguments:
+ jid -- The JID object to test.
+ user -- Optional. The user name portion of the JID.
+ domain -- Optional. The domain name portion of the JID.
+ resource -- Optional. The resource portion of the JID.
+ bare -- Optional. The bare JID.
+ full -- Optional. The full JID.
+ string -- Optional. The string version of the JID.
+ """
+ if user is not None:
+ self.assertEqual(jid.user, user,
+ "User does not match: %s" % jid.user)
+ if domain is not None:
+ self.assertEqual(jid.domain, domain,
+ "Domain does not match: %s" % jid.domain)
+ if resource is not None:
+ self.assertEqual(jid.resource, resource,
+ "Resource does not match: %s" % jid.resource)
+ if bare is not None:
+ self.assertEqual(jid.bare, bare,
+ "Bare JID does not match: %s" % jid.bare)
+ if full is not None:
+ self.assertEqual(jid.full, full,
+ "Full JID does not match: %s" % jid.full)
+ if string is not None:
+ self.assertEqual(str(jid), string,
+ "String does not match: %s" % str(jid))
+
# ------------------------------------------------------------------
# Methods for comparing stanza objects to XML strings
diff --git a/sleekxmpp/xmlstream/jid.py b/sleekxmpp/xmlstream/jid.py
index 7362814e..149611b7 100644
--- a/sleekxmpp/xmlstream/jid.py
+++ b/sleekxmpp/xmlstream/jid.py
@@ -57,7 +57,7 @@ class JID(object):
full, or bare.
"""
if name == 'resource':
- if self._resource is None:
+ if self._resource is None and '/' in self._jid:
self._resource = self._jid.split('/', 1)[-1]
return self._resource or ""
elif name == 'user':