From 65aa6573df3a8f298e7df96473014c19216971ef Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 26 Oct 2010 23:47:17 -0400 Subject: First pass at integrating the new roster manager. --- tests/test_stanza_roster.py | 4 ++++ tests/test_stream_presence.py | 34 +++++++++++++++++++++++++--------- tests/test_stream_roster.py | 40 +++++++++++++++++----------------------- 3 files changed, 46 insertions(+), 32 deletions(-) (limited to 'tests') diff --git a/tests/test_stanza_roster.py b/tests/test_stanza_roster.py index a0e57987..443eab3e 100644 --- a/tests/test_stanza_roster.py +++ b/tests/test_stanza_roster.py @@ -48,10 +48,14 @@ class TestRosterStanzas(SleekTest): 'user@example.com': { 'name': 'User', 'subscription': 'both', + 'ask': '', + 'approved': '', 'groups': ['Friends', 'Coworkers']}, 'otheruser@example.com': { 'name': 'Other User', 'subscription': 'both', + 'ask': '', + 'approved': '', 'groups': []}} debug = "Roster items don't match after retrieval." debug += "\nReturned: %s" % str(iq['roster']['items']) diff --git a/tests/test_stream_presence.py b/tests/test_stream_presence.py index ca67f1df..c873799a 100644 --- a/tests/test_stream_presence.py +++ b/tests/test_stream_presence.py @@ -30,7 +30,9 @@ class TestStreamPresence(SleekTest): self.xmpp.add_event_handler('presence_unavailable', unavailable) self.stream_recv(""" - + """) # Give event queue time to process. @@ -68,12 +70,14 @@ class TestStreamPresence(SleekTest): # Contact comes online. self.stream_recv(""" - + """) # Contact goes offline, should trigger got_offline. self.stream_recv(""" """) @@ -99,7 +103,8 @@ class TestStreamPresence(SleekTest): self.xmpp.add_event_handler('got_online', got_online) self.stream_recv(""" - + """) # Give event queue time to process. @@ -136,15 +141,23 @@ class TestStreamPresence(SleekTest): self.xmpp.auto_subscribe = True self.stream_recv(""" - + + """) + + self.stream_send_presence(""" + """) self.stream_send_presence(""" - + """) self.stream_send_presence(""" - + """) expected = set(('presence_subscribe', 'changed_subscription')) @@ -170,14 +183,17 @@ class TestStreamPresence(SleekTest): presence_subscribe) # With this setting we should reject all subscriptions. - self.xmpp.auto_authorize = False + self.xmpp.rosters['tester@localhost'].auto_authorize = False self.stream_recv(""" - + """) self.stream_send_presence(""" - + """) expected = set(('presence_subscribe', 'changed_subscription')) diff --git a/tests/test_stream_roster.py b/tests/test_stream_roster.py index 6eda7e3e..67da6e6c 100644 --- a/tests/test_stream_roster.py +++ b/tests/test_stream_roster.py @@ -13,8 +13,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') # Since get_roster blocks, we need to run it in a thread. t = threading.Thread(name='get_roster', target=self.xmpp.get_roster) @@ -26,11 +25,12 @@ class TestStreamRoster(SleekTest): """) self.stream_recv(""" - + + subscription="from" + ask="subscribe"> Friends Examples @@ -41,21 +41,20 @@ class TestStreamRoster(SleekTest): # Wait for get_roster to return. t.join() - 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) + print self.xmpp.rosters['tester@localhost']['user@localhost']._state + self.check_roster('tester@localhost', 'user@localhost', + name='User', + subscription='from', + afrom=True, + pending_out=True, + groups=['Friends', 'Examples']) def testRosterSet(self): """Test handling pushed roster updates.""" - self.stream_start(mode='client') - self.failUnless(self.xmpp.roster == {}, "Initial roster not empty.") + self.stream_start(mode='client', jid='tester@localhost') self.stream_recv(""" - + """) - 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.check_roster('tester@localhost', 'user@localhost', + name='User', + subscription='both', + groups=['Friends', 'Examples']) suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamRoster) -- cgit v1.2.3