From 4610a6615c04c95a73b3fe0771e5a07f68a20d5c Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Wed, 7 Mar 2012 16:11:59 -0800 Subject: Add tests for roster versioning. --- tests/test_stream_roster.py | 125 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) (limited to 'tests') diff --git a/tests/test_stream_roster.py b/tests/test_stream_roster.py index eb6d2f4f..535a0080 100644 --- a/tests/test_stream_roster.py +++ b/tests/test_stream_roster.py @@ -104,6 +104,74 @@ class TestStreamRoster(SleekTest): self.failUnless('roster_update' in events, "Roster updated event not triggered: %s" % events) + def testRosterPushRemove(self): + """Test handling roster item removal updates.""" + self.stream_start(mode='client') + events = [] + + # Add roster item + self.recv(""" + + + + Friends + Examples + + + + """) + self.send(""" + + + + """) + + self.assertTrue('user@localhost' in self.xmpp.client_roster) + + # Receive item remove push + self.recv(""" + + + + + + + """) + self.send(""" + + + + """) + + self.assertTrue('user@localhost' not in self.xmpp.client_roster) + + def testUnauthorizedRosterPush(self): + """Test rejecting a roster push from an unauthorized source.""" + self.stream_start() + self.recv(""" + + + + Friends + Examples + + + + """) + self.send(""" + + + + + + """) + def testRosterTimeout(self): """Test handling a timed out roster request.""" self.stream_start() @@ -227,5 +295,62 @@ class TestStreamRoster(SleekTest): """) + def testUnsupportedRosterVer(self): + """Test working with a server without roster versioning.""" + 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.send(""" + + + + """) + self.recv(""" + + """) + + 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.send(""" + + + + """) + self.recv(""" + + """) + + t.join() + + + def testExistingRosterVer(self): + """Test using a stored roster version.""" + self.stream_start() + 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.send(""" + + + + """) + self.recv(""" + + """) + + t.join() + suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamRoster) -- cgit v1.2.3