[telepathy-gabble/master] Test more ways to rescind subscription requests.
Will Thompson
will.thompson at collabora.co.uk
Mon Jul 20 10:40:09 PDT 2009
Rescinding requests by sending <presence type='unsubscribe'/> is
currently broken by the workarounds for Google Talk's flickering bug.
---
tests/twisted/roster/removed-from-rp-subscribe.py | 112 +++++++++++++++------
1 files changed, 83 insertions(+), 29 deletions(-)
diff --git a/tests/twisted/roster/removed-from-rp-subscribe.py b/tests/twisted/roster/removed-from-rp-subscribe.py
index 7d44591..1c6c33b 100644
--- a/tests/twisted/roster/removed-from-rp-subscribe.py
+++ b/tests/twisted/roster/removed-from-rp-subscribe.py
@@ -1,18 +1,17 @@
"""
-Regression test for reacting to other clients making and then rescinding
-subscription requests while we're online.
+Regression tests for rescinding outstanding subscription requests.
"""
from twisted.words.protocols.jabber.client import IQ
-from servicetest import tp_path_prefix, EventPattern
-from gabbletest import exec_test, expect_list_channel
+from servicetest import tp_path_prefix, EventPattern, assertEquals
+from gabbletest import exec_test, expect_list_channel, GoogleXmlStream
import constants as cs
import ns
jid = 'marco at barisione.lit'
-def test(q, bus, conn, stream):
+def test(q, bus, conn, stream, remove, local):
conn.Connect()
# Gabble asks for the roster; the server sends back an empty roster.
@@ -67,31 +66,86 @@ def test(q, bus, conn, stream):
args=['', [], [], [], [h], 0, 0],
path=subscribe.object_path[len(tp_path_prefix):])
- # The user driving Gajim decides that they don't care what Marco's baking
- # after all (maybe they read his blog instead?) and removes him from the
- # roster. The server must 'inform all of the user's available resources
- # that have requested the roster of the roster item removal':
- iq = IQ(stream, "set")
- item = iq.addElement((ns.ROSTER, 'query')).addElement('item')
- item['jid'] = jid
- item['subscription'] = 'remove'
- # When Marco found this bug, this roster update included:
- item['ask'] = 'subscribe'
- # which is a bit weird: I don't think the server should send that when the
- # contact's being removed. I think Gabble should ignore it, so I'm
- # including it in the test.
- stream.send(iq)
+ # The user decides that they don't care what Marco's baking after all
+ # (maybe they read his blog instead?) and:
+ if remove:
+ # ...removes him from the roster...
+ if local:
+ # ...by telling Gabble to remove him from stored.
+ stored.Group.RemoveMembers([h], '')
- # In response, Gabble should announce that Marco has been removed from
- # subscribe:remote-pending and stored:members:
- q.expect_many(
- EventPattern('dbus-signal', signal='MembersChanged',
- args=['', [], [h], [], [], 0, 0],
- path=subscribe.object_path[len(tp_path_prefix):]),
- EventPattern('dbus-signal', signal='MembersChanged',
+ event = q.expect('stream-iq', iq_type='set', query_ns=ns.ROSTER)
+ item = event.query.firstChildElement()
+ assertEquals(jid, item['jid'])
+ assertEquals('remove', item['subscription'])
+ else:
+ # ...using the other client.
+ pass
+
+ # The server must 'inform all of the user's available resources that
+ # have requested the roster of the roster item removal':
+ iq = IQ(stream, "set")
+ item = iq.addElement((ns.ROSTER, 'query')).addElement('item')
+ item['jid'] = jid
+ item['subscription'] = 'remove'
+ # When Marco found this bug, this roster update included:
+ item['ask'] = 'subscribe'
+ # which is a bit weird: I don't think the server should send that when
+ # the contact's being removed. I think Gabble should ignore it, so I'm
+ # including it in the test.
+ stream.send(iq)
+
+ # In response, Gabble should announce that Marco has been removed from
+ # subscribe:remote-pending and stored:members:
+ q.expect_many(
+ EventPattern('dbus-signal', signal='MembersChanged',
+ args=['', [], [h], [], [], 0, 0],
+ path=subscribe.object_path[len(tp_path_prefix):]),
+ EventPattern('dbus-signal', signal='MembersChanged',
+ args=['', [], [h], [], [], 0, 0],
+ path=stored.object_path[len(tp_path_prefix):]),
+ )
+ else:
+ # ...rescinds the subscription request...
+ if local:
+ # ...by telling Gabble to remove him from 'subscribe'.
+ subscribe.Group.RemoveMembers([h], '')
+
+ q.expect('stream-presence', to=jid, presence_type='unsubscribe')
+ else:
+ # ...in the other client.
+ pass
+
+ # In response, the server sends a roster update:
+ iq = IQ(stream, "set")
+ item = iq.addElement((ns.ROSTER, 'query')).addElement('item')
+ item['jid'] = jid
+ item['subscription'] = 'none'
+ # no ask='subscribe' any more.
+ stream.send(iq)
+
+ # In response, Gabble should announce that Marco has been removed from
+ # subscribe:remote-pending. It shouldn't wait for the <presence
+ # type='unsubscribed'/> ack before doing so: empirical tests reveal
+ # that it's never delivered.
+ q.expect('dbus-signal', signal='MembersChanged',
args=['', [], [h], [], [], 0, 0],
- path=stored.object_path[len(tp_path_prefix):]),
- )
+ path=subscribe.object_path[len(tp_path_prefix):])
+
+def test_remove_local(q, bus, conn, stream):
+ test(q, bus, conn, stream, remove=True, local=True)
+
+def test_unsubscribe_local(q, bus, conn, stream):
+ test(q, bus, conn, stream, remove=False, local=True)
+
+def test_remove_remote(q, bus, conn, stream):
+ test(q, bus, conn, stream, remove=True, local=False)
+
+def test_unsubscribe_remote(q, bus, conn, stream):
+ test(q, bus, conn, stream, remove=False, local=False)
if __name__ == '__main__':
- exec_test(test)
+ exec_test(test_remove_local)
+ exec_test(test_unsubscribe_local)
+ exec_test(test_remove_remote)
+ exec_test(test_unsubscribe_remote)
--
1.5.6.5
More information about the telepathy-commits
mailing list