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.py71
1 files changed, 30 insertions, 41 deletions
diff --git a/tests/test_stream_roster.py b/tests/test_stream_roster.py
index 15b8683a..7f18c312 100644
--- a/tests/test_stream_roster.py
+++ b/tests/test_stream_roster.py
@@ -17,8 +17,7 @@ class TestStreamRoster(SleekTest):
def testGetRoster(self):
"""Test handling roster requests."""
- self.stream_start(mode='client')
- self.failUnless(self.xmpp.roster == {}, "Initial roster not empty.")
+ self.stream_start(mode='client', jid='tester@localhost')
events = []
@@ -37,11 +36,12 @@ class TestStreamRoster(SleekTest):
</iq>
""")
self.recv("""
- <iq type="result" id="1">
+ <iq to='tester@localhost' type="result" id="1">
<query xmlns="jabber:iq:roster">
<item jid="user@localhost"
name="User"
- subscription="both">
+ subscription="from"
+ ask="subscribe">
<group>Friends</group>
<group>Examples</group>
</item>
@@ -52,23 +52,22 @@ class TestStreamRoster(SleekTest):
# Wait for get_roster to return.
t.join()
+ self.check_roster('tester@localhost', 'user@localhost',
+ name='User',
+ subscription='from',
+ afrom=True,
+ pending_out=True,
+ groups=['Friends', 'Examples'])
+
# Give the event queue time to process.
time.sleep(.1)
- roster = {'user@localhost': {'name': 'User',
- 'subscription': 'both',
- 'groups': ['Friends', 'Examples'],
- 'presence': {},
- 'in_roster': True}}
- self.failUnless(self.xmpp.roster == roster,
- "Unexpected roster values: %s" % self.xmpp.roster)
self.failUnless('roster_received' in events,
"Roster received event not triggered: %s" % events)
def testRosterSet(self):
"""Test handling pushed roster updates."""
self.stream_start(mode='client')
- self.failUnless(self.xmpp.roster == {}, "Initial roster not empty.")
events = []
def roster_update(e):
@@ -76,9 +75,8 @@ class TestStreamRoster(SleekTest):
self.xmpp.add_event_handler('roster_update', roster_update)
-
self.recv("""
- <iq type="set" id="1">
+ <iq to='tester@localhost' type="set" id="1">
<query xmlns="jabber:iq:roster">
<item jid="user@localhost"
name="User"
@@ -95,16 +93,14 @@ class TestStreamRoster(SleekTest):
</iq>
""")
+ self.check_roster('tester@localhost', 'user@localhost',
+ name='User',
+ subscription='both',
+ groups=['Friends', 'Examples'])
+
# Give the event queue time to process.
time.sleep(.1)
- roster = {'user@localhost': {'name': 'User',
- 'subscription': 'both',
- 'groups': ['Friends', 'Examples'],
- 'presence': {},
- 'in_roster': True}}
- self.failUnless(self.xmpp.roster == roster,
- "Unexpected roster values: %s" % self.xmpp.roster)
self.failUnless('roster_update' in events,
"Roster updated event not triggered: %s" % events)
@@ -182,14 +178,13 @@ class TestStreamRoster(SleekTest):
# 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.check_roster('tester@localhost', 'andré@foo',
+ subscription='both',
+ groups=['Unicode'])
+
+ jids = self.xmpp.client_roster.keys()
+ self.failUnless(jids == ['andré@foo'],
+ "Too many roster entries found: %s" % jids)
self.recv("""
<presence to="tester@localhost" from="andré@foo/bar">
@@ -201,18 +196,12 @@ class TestStreamRoster(SleekTest):
# 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)
-
+ result = self.xmpp.client_roster['andré@foo'].resources
+ expected = {'bar': {'status':'Testing',
+ 'show':'away',
+ 'priority':0}}
+ self.failUnless(result == expected,
+ "Unexpected roster values: %s" % result)
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamRoster)