mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-30 19:19:55 +00:00
Merge branch 'develop' into stream_features
This commit is contained in:
commit
9851a2a057
4 changed files with 66 additions and 6 deletions
|
@ -16,7 +16,8 @@ import sleekxmpp
|
|||
from sleekxmpp import ClientXMPP, ComponentXMPP
|
||||
from sleekxmpp.stanza import Message, Iq, Presence
|
||||
from sleekxmpp.test import TestSocket, TestLiveSocket
|
||||
from sleekxmpp.xmlstream import StanzaBase, ET, register_stanza_plugin
|
||||
from sleekxmpp.xmlstream import ET, register_stanza_plugin
|
||||
from sleekxmpp.xmlstream import ElementBase, StanzaBase
|
||||
from sleekxmpp.xmlstream.tostring import tostring
|
||||
from sleekxmpp.xmlstream.matcher import StanzaPath, MatcherId
|
||||
from sleekxmpp.xmlstream.matcher import MatchXMLMask, MatchXPath
|
||||
|
@ -201,7 +202,7 @@ class SleekTest(unittest.TestCase):
|
|||
"Stanza:\n%s" % str(stanza))
|
||||
else:
|
||||
stanza_class = stanza.__class__
|
||||
if isinstance(criteria, str):
|
||||
if not isinstance(criteria, ElementBase):
|
||||
xml = self.parse_xml(criteria)
|
||||
else:
|
||||
xml = criteria.xml
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
See the file LICENSE for copying permission.
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
|
||||
class JID(object):
|
||||
"""
|
||||
|
@ -42,7 +44,9 @@ class JID(object):
|
|||
Arguments:
|
||||
jid - The new JID value.
|
||||
"""
|
||||
self._full = self._jid = str(jid)
|
||||
if isinstance(jid, JID):
|
||||
jid = jid.full
|
||||
self._full = self._jid = jid
|
||||
self._domain = None
|
||||
self._resource = None
|
||||
self._user = None
|
||||
|
@ -123,10 +127,11 @@ class JID(object):
|
|||
return self.full
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
return self.full
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
Two JIDs are considered equal if they have the same full JID value.
|
||||
"""
|
||||
return str(other) == str(self)
|
||||
other = JID(other)
|
||||
return self.full == other.full
|
||||
|
|
|
@ -104,6 +104,9 @@ class TestHandlers(SleekTest):
|
|||
iq['query'] = 'test2'
|
||||
self.send(iq)
|
||||
|
||||
# Give the event queue time to process.
|
||||
time.sleep(0.1)
|
||||
|
||||
# Check that the waiter is no longer registered
|
||||
waiter_exists = self.xmpp.removeHandler('IqWait_test2')
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
# -*- encoding:utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from sleekxmpp.test import *
|
||||
import time
|
||||
import threading
|
||||
|
@ -162,6 +166,53 @@ class TestStreamRoster(SleekTest):
|
|||
self.failUnless(events == ['roster_callback'],
|
||||
"Roster timeout event not triggered: %s." % events)
|
||||
|
||||
def testRosterUnicode(self):
|
||||
"""Test that JIDs with Unicode values are handled properly."""
|
||||
self.stream_start()
|
||||
self.recv("""
|
||||
<iq to="tester@localhost" type="set" id="1">
|
||||
<query xmlns="jabber:iq:roster">
|
||||
<item jid="andré@foo" subscription="both">
|
||||
<group>Unicode</group>
|
||||
</item>
|
||||
</query>
|
||||
</iq>
|
||||
""")
|
||||
|
||||
# Give the event queue time to process.
|
||||
time.sleep(.1)
|
||||
|
||||
roster = {'andré@foo': {
|
||||
'name': '',
|
||||
'subscription': 'both',
|
||||
'groups': ['Unicode'],
|
||||
'presence': {},
|
||||
'in_roster': True}}
|
||||
self.failUnless(self.xmpp.roster == roster,
|
||||
"Unexpected roster values: %s" % self.xmpp.roster)
|
||||
|
||||
self.recv("""
|
||||
<presence to="tester@localhost" from="andré@foo/bar">
|
||||
<show>away</show>
|
||||
<status>Testing</status>
|
||||
</presence>
|
||||
""")
|
||||
|
||||
# Give the event queue time to process.
|
||||
time.sleep(.1)
|
||||
|
||||
roster = {'andré@foo': {
|
||||
'name': '',
|
||||
'subscription': 'both',
|
||||
'groups': ['Unicode'],
|
||||
'presence': {
|
||||
'bar':{'priority':0,
|
||||
'status':'Testing',
|
||||
'show':'away'}},
|
||||
'in_roster': True}}
|
||||
self.failUnless(self.xmpp.roster == roster,
|
||||
"Unexpected roster values: %s" % self.xmpp.roster)
|
||||
|
||||
|
||||
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamRoster)
|
||||
|
|
Loading…
Reference in a new issue