From 04a9f4ae992cf5edbe62320876f7eade529e3568 Mon Sep 17 00:00:00 2001 From: Cosimo Alfarano Date: Wed, 2 Nov 2011 13:24:09 +0000 Subject: [PATCH 4/4] add case for "cancel subscription" to test_local_pending --- tests/twisted/roster/test-google-roster.py | 29 ++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) diff --git a/tests/twisted/roster/test-google-roster.py b/tests/twisted/roster/test-google-roster.py index b419cd9..3773377 100644 --- a/tests/twisted/roster/test-google-roster.py +++ b/tests/twisted/roster/test-google-roster.py @@ -305,6 +305,35 @@ def test_local_pending(q, bus, conn, stream, subscribe): sync_dbus(bus, q, conn) q.unforbid_events([change_event]) + # Now we cancel alice's subscription request and verify that if the + # redundant IQ is sent again, it's safely handled + presence = domish.Element(('jabber:client', 'presence')) + presence['from'] = contact + presence['type'] = 'unsubscribe' + stream.send(presence) + + q.expect_many( + EventPattern('dbus-signal', signal='MembersChanged', + args=['', [], [handle], [], [], handle, cs.GC_REASON_NONE], + predicate=is_publish), + EventPattern('dbus-signal', signal='ContactsChanged', + args=[{handle: (cs.SUBSCRIPTION_STATE_NO, + cs.SUBSCRIPTION_STATE_REMOVED_REMOTELY, '')}, []]), + ) + + # Now we send a roster roster update with subscribe="none" again (which + # doesn't change anything, it just confirms what we already knew) and + # verify that nothing happens to her publish state in reaction to that. + q.forbid_events([change_event]) + + iq = make_set_roster_iq(stream, 'test@localhost/Resource', contact, + "none", False) + stream.send(iq) + + sync_stream(q, stream) + sync_dbus(bus, q, conn) + q.unforbid_events([change_event]) + # This event is forbidden in all of the deny tests! remove_events = [ EventPattern('stream-iq', query_ns=ns.ROSTER, -- 1.7.7