[telepathy-mission-control/master] dispatcher/dispatch-rejected-by-plugin.py: exercise all of the special usernames
Simon McVittie
simon.mcvittie at collabora.co.uk
Tue Jun 30 10:37:00 PDT 2009
---
.../dispatcher/dispatch-rejected-by-plugin.py | 132 ++++++++++++++++++--
1 files changed, 123 insertions(+), 9 deletions(-)
diff --git a/test/twisted/dispatcher/dispatch-rejected-by-plugin.py b/test/twisted/dispatcher/dispatch-rejected-by-plugin.py
index b77919b..272eac3 100644
--- a/test/twisted/dispatcher/dispatch-rejected-by-plugin.py
+++ b/test/twisted/dispatcher/dispatch-rejected-by-plugin.py
@@ -73,18 +73,21 @@ def test(q, bus, mc):
# This ID is special-cased by the test-plugin plugin, which rejects
# channels to or from it
+ target = 'rick.astley at example.com'
channel_properties = dbus.Dictionary(text_fixed_properties,
signature='sv')
- channel_properties[cs.CHANNEL + '.TargetID'] = 'rick.astley at example.com'
+ channel_properties[cs.CHANNEL + '.TargetID'] = target
channel_properties[cs.CHANNEL + '.TargetHandle'] = \
- conn.ensure_handle(cs.HT_CONTACT, 'rick.astley at example.com')
- channel_properties[cs.CHANNEL + '.InitiatorID'] = 'rick.astley at example.com'
+ conn.ensure_handle(cs.HT_CONTACT, target)
+ channel_properties[cs.CHANNEL + '.InitiatorID'] = target
channel_properties[cs.CHANNEL + '.InitiatorHandle'] = \
- conn.ensure_handle(cs.HT_CONTACT, 'rick.astley at example.com')
+ conn.ensure_handle(cs.HT_CONTACT, target)
channel_properties[cs.CHANNEL + '.Requested'] = False
- channel_properties[cs.CHANNEL + '.Interfaces'] = dbus.Array(signature='s')
+ channel_properties[cs.CHANNEL + '.Interfaces'] = \
+ dbus.Array([cs.CHANNEL_IFACE_DESTROYABLE, cs.CHANNEL_IFACE_GROUP,
+ ],signature='s')
- chan = SimulatedChannel(conn, channel_properties)
+ chan = SimulatedChannel(conn, channel_properties, group=True)
chan.announce()
# A channel dispatch operation is created
@@ -107,10 +110,12 @@ def test(q, bus, mc):
cs.tp_name_prefix + '.Client.Kopete'], handlers
# The plugin realises we've been rickrolled, and responds
- q.expect('dbus-method-call',
+ e = q.expect('dbus-method-call',
path=chan.object_path,
- interface=cs.CHANNEL, method='Close', args=[],
- handled=True)
+ interface=cs.CHANNEL_IFACE_DESTROYABLE, method='Destroy', args=[],
+ handled=False)
+ # treat it like Close
+ chan.Close(e)
q.expect_many(
EventPattern('dbus-signal', path=cdo_path,
@@ -121,5 +126,114 @@ def test(q, bus, mc):
args=[cdo_path]),
)
+ # This ID is also special-cased
+ target = 'mc.hammer at example.com'
+ channel_properties = dbus.Dictionary(text_fixed_properties,
+ signature='sv')
+ channel_properties[cs.CHANNEL + '.TargetID'] = target
+ channel_properties[cs.CHANNEL + '.TargetHandle'] = \
+ conn.ensure_handle(cs.HT_CONTACT, target)
+ channel_properties[cs.CHANNEL + '.InitiatorID'] = target
+ channel_properties[cs.CHANNEL + '.InitiatorHandle'] = \
+ conn.ensure_handle(cs.HT_CONTACT, target)
+ channel_properties[cs.CHANNEL + '.Requested'] = False
+ channel_properties[cs.CHANNEL + '.Interfaces'] = \
+ dbus.Array([cs.CHANNEL_IFACE_DESTROYABLE, cs.CHANNEL_IFACE_GROUP,
+ ],signature='s')
+
+ chan = SimulatedChannel(conn, channel_properties, group=True)
+ chan.announce()
+
+ # A channel dispatch operation is created
+
+ e = q.expect('dbus-signal',
+ path=cs.CD_PATH,
+ interface=cs.CD_IFACE_OP_LIST,
+ signal='NewDispatchOperation')
+
+ cdo_path = e.args[0]
+ cdo_properties = e.args[1]
+
+ assert cdo_properties[cs.CDO + '.Account'] == account.object_path
+ assert cdo_properties[cs.CDO + '.Connection'] == conn.object_path
+ assert cs.CDO + '.Interfaces' in cdo_properties
+
+ handlers = cdo_properties[cs.CDO + '.PossibleHandlers'][:]
+ handlers.sort()
+ assert handlers == [cs.tp_name_prefix + '.Client.Empathy',
+ cs.tp_name_prefix + '.Client.Kopete'], handlers
+
+ # The plugin realises it's MC Hammer, and responds
+ e = q.expect('dbus-method-call',
+ path=chan.object_path,
+ interface=cs.CHANNEL_IFACE_DESTROYABLE, method='Destroy', args=[],
+ handled=False)
+ # treat it like Close
+ chan.Close(e)
+
+ q.expect_many(
+ EventPattern('dbus-signal', path=cdo_path,
+ interface=cs.CDO, signal='Finished'),
+ EventPattern('dbus-signal', path=cs.CD_PATH,
+ interface=cs.CD_IFACE_OP_LIST,
+ signal='DispatchOperationFinished',
+ args=[cdo_path]),
+ )
+
+ # This ID is *also* special-cased
+ target = 'hammertime at example.com'
+ channel_properties = dbus.Dictionary(text_fixed_properties,
+ signature='sv')
+ channel_properties[cs.CHANNEL + '.TargetID'] = target
+ channel_properties[cs.CHANNEL + '.TargetHandle'] = \
+ conn.ensure_handle(cs.HT_CONTACT, target)
+ channel_properties[cs.CHANNEL + '.InitiatorID'] = target
+ channel_properties[cs.CHANNEL + '.InitiatorHandle'] = \
+ conn.ensure_handle(cs.HT_CONTACT, target)
+ channel_properties[cs.CHANNEL + '.Requested'] = False
+ channel_properties[cs.CHANNEL + '.Interfaces'] = \
+ dbus.Array([cs.CHANNEL_IFACE_DESTROYABLE, cs.CHANNEL_IFACE_GROUP,
+ ],signature='s')
+
+ chan = SimulatedChannel(conn, channel_properties, group=True)
+ chan.announce()
+
+ # A channel dispatch operation is created
+
+ e = q.expect('dbus-signal',
+ path=cs.CD_PATH,
+ interface=cs.CD_IFACE_OP_LIST,
+ signal='NewDispatchOperation')
+
+ cdo_path = e.args[0]
+ cdo_properties = e.args[1]
+
+ assert cdo_properties[cs.CDO + '.Account'] == account.object_path
+ assert cdo_properties[cs.CDO + '.Connection'] == conn.object_path
+ assert cs.CDO + '.Interfaces' in cdo_properties
+
+ handlers = cdo_properties[cs.CDO + '.PossibleHandlers'][:]
+ handlers.sort()
+ assert handlers == [cs.tp_name_prefix + '.Client.Empathy',
+ cs.tp_name_prefix + '.Client.Kopete'], handlers
+
+ # The plugin realises it's MC Hammer, and responds
+ _, _, e = q.expect_many(
+ EventPattern('dbus-signal', path=cdo_path,
+ interface=cs.CDO, signal='Finished'),
+ EventPattern('dbus-signal', path=cs.CD_PATH,
+ interface=cs.CD_IFACE_OP_LIST,
+ signal='DispatchOperationFinished',
+ args=[cdo_path]),
+ EventPattern('dbus-method-call',
+ path=chan.object_path,
+ interface=cs.CHANNEL_IFACE_GROUP,
+ method='RemoveMembersWithReason', args=[[conn.self_handle],
+ "Can't touch this", cs.GROUP_REASON_PERMISSION_DENIED],
+ handled=False),
+ )
+ q.dbus_return(e.message, signature='')
+ chan.close()
+
if __name__ == '__main__':
exec_test(test, {})
--
1.5.6.5
More information about the telepathy-commits
mailing list