summaryrefslogtreecommitdiff
path: root/tests/test_stream_roster.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-05-20 16:48:13 -0400
committerLance Stout <lancestout@gmail.com>2011-05-20 16:48:13 -0400
commit6b274a2543744f9b94823f5bd2a6c23ec8cc3f75 (patch)
tree6272aac508277e9ce0f14c8c15912719d616a575 /tests/test_stream_roster.py
parent6a07e7cbe3e995f44ca3ba75a0ff83616269cf5a (diff)
downloadslixmpp-6b274a2543744f9b94823f5bd2a6c23ec8cc3f75.tar.gz
slixmpp-6b274a2543744f9b94823f5bd2a6c23ec8cc3f75.tar.bz2
slixmpp-6b274a2543744f9b94823f5bd2a6c23ec8cc3f75.tar.xz
slixmpp-6b274a2543744f9b94823f5bd2a6c23ec8cc3f75.zip
Fix double roster entry issue with Unicode.
JIDs with Unicode values were being encoded by the JID class instead of leaving them as just Unicode strings. It may still be a good idea to use from __future__ import unicode_literals pretty much everywhere though. Fixes issue #88.
Diffstat (limited to 'tests/test_stream_roster.py')
-rw-r--r--tests/test_stream_roster.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/test_stream_roster.py b/tests/test_stream_roster.py
index 731d1145..d86ff955 100644
--- a/tests/test_stream_roster.py
+++ b/tests/test_stream_roster.py
@@ -1,3 +1,7 @@
+# -*- encoding:utf-8 -*-
+
+from __future__ import unicode_literals
+
from sleekxmpp.test import *
import time
import threading
@@ -162,6 +166,50 @@ 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 from="andré@foo/bar" />
+ """)
+
+ # Give the event queue time to process.
+ time.sleep(.1)
+
+ roster = {'andré@foo': {
+ 'name': '',
+ 'subscription': 'both',
+ 'groups': ['Unicode'],
+ 'presence': {
+ 'bar':{'priority':0,
+ 'status':'',
+ 'show':'available'}},
+ 'in_roster': True}}
+ self.failUnless(self.xmpp.roster == roster,
+ "Unexpected roster values: %s" % self.xmpp.roster)
+
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamRoster)