summaryrefslogtreecommitdiff
path: root/tests/test_stream_roster.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_stream_roster.py')
-rw-r--r--tests/test_stream_roster.py65
1 files changed, 11 insertions, 54 deletions
diff --git a/tests/test_stream_roster.py b/tests/test_stream_roster.py
index 221954ab..6a171ce7 100644
--- a/tests/test_stream_roster.py
+++ b/tests/test_stream_roster.py
@@ -2,13 +2,13 @@
from __future__ import unicode_literals
import unittest
-from sleekxmpp.exceptions import IqTimeout
-from sleekxmpp.test import SleekTest
+from slixmpp.exceptions import IqTimeout
+from slixmpp.test import SlixTest
import time
import threading
-class TestStreamRoster(SleekTest):
+class TestStreamRoster(SlixTest):
"""
Test handling roster updates.
"""
@@ -24,9 +24,7 @@ class TestStreamRoster(SleekTest):
self.xmpp.add_event_handler('roster_update', roster_updates.append)
- # Since get_roster blocks, we need to run it in a thread.
- t = threading.Thread(name='get_roster', target=self.xmpp.get_roster)
- t.start()
+ self.xmpp.get_roster()
self.send("""
<iq type="get" id="1">
@@ -47,12 +45,6 @@ class TestStreamRoster(SleekTest):
</iq>
""")
- # Wait for get_roster to return.
- t.join()
-
- # Give the event queue time to process.
- time.sleep(.1)
-
self.check_roster('tester@localhost', 'user@localhost',
name='User',
subscription='from',
@@ -96,8 +88,6 @@ class TestStreamRoster(SleekTest):
subscription='both',
groups=['Friends', 'Examples'])
- # Give the event queue time to process.
- time.sleep(.1)
self.failUnless('roster_update' in events,
"Roster updated event not triggered: %s" % events)
@@ -170,16 +160,6 @@ class TestStreamRoster(SleekTest):
</iq>
""")
- def testRosterTimeout(self):
- """Test handling a timed out roster request."""
- self.stream_start()
-
- def do_test():
- self.xmpp.get_roster(timeout=0)
- time.sleep(.1)
-
- self.assertRaises(IqTimeout, do_test)
-
def testRosterCallback(self):
"""Test handling a roster request callback."""
self.stream_start()
@@ -188,12 +168,7 @@ class TestStreamRoster(SleekTest):
def roster_callback(iq):
events.append('roster_callback')
- # Since get_roster blocks, we need to run it in a thread.
- t = threading.Thread(name='get_roster',
- target=self.xmpp.get_roster,
- kwargs={str('block'): False,
- str('callback'): roster_callback})
- t.start()
+ self.xmpp.get_roster(callback=roster_callback)
self.send("""
<iq type="get" id="1">
@@ -213,12 +188,6 @@ class TestStreamRoster(SleekTest):
</iq>
""")
- # Wait for get_roster to return.
- t.join()
-
- # Give the event queue time to process.
- time.sleep(.1)
-
self.failUnless(events == ['roster_callback'],
"Roster timeout event not triggered: %s." % events)
@@ -235,9 +204,6 @@ class TestStreamRoster(SleekTest):
</iq>
""")
- # Give the event queue time to process.
- time.sleep(.1)
-
self.check_roster('tester@localhost', 'andré@foo',
subscription='both',
groups=['Unicode'])
@@ -253,9 +219,6 @@ class TestStreamRoster(SleekTest):
</presence>
""")
- # Give the event queue time to process.
- time.sleep(.1)
-
result = self.xmpp.client_roster['andré@foo'].resources
expected = {'bar': {'status':'Testing',
'show':'away',
@@ -298,8 +261,8 @@ class TestStreamRoster(SleekTest):
self.stream_start()
self.assertTrue('rosterver' not in self.xmpp.features)
- t = threading.Thread(name='get_roster', target=self.xmpp.get_roster)
- t.start()
+ self.xmpp.get_roster()
+
self.send("""
<iq type="get" id="1">
<query xmlns="jabber:iq:roster" />
@@ -309,16 +272,14 @@ class TestStreamRoster(SleekTest):
<iq to="tester@localhost" type="result" id="1" />
""")
- t.join()
-
def testBootstrapRosterVer(self):
"""Test bootstrapping with roster versioning."""
self.stream_start()
self.xmpp.features.add('rosterver')
self.xmpp.client_roster.version = ''
- t = threading.Thread(name='get_roster', target=self.xmpp.get_roster)
- t.start()
+ self.xmpp.get_roster()
+
self.send("""
<iq type="get" id="1">
<query xmlns="jabber:iq:roster" ver="" />
@@ -328,8 +289,6 @@ class TestStreamRoster(SleekTest):
<iq to="tester@localhost" type="result" id="1" />
""")
- t.join()
-
def testExistingRosterVer(self):
"""Test using a stored roster version."""
@@ -337,8 +296,8 @@ class TestStreamRoster(SleekTest):
self.xmpp.features.add('rosterver')
self.xmpp.client_roster.version = '42'
- t = threading.Thread(name='get_roster', target=self.xmpp.get_roster)
- t.start()
+ self.xmpp.get_roster()
+
self.send("""
<iq type="get" id="1">
<query xmlns="jabber:iq:roster" ver="42" />
@@ -348,7 +307,5 @@ class TestStreamRoster(SleekTest):
<iq to="tester@localhost" type="result" id="1" />
""")
- t.join()
-
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamRoster)