[telepathy-mission-control/master] tests: stop asserting that MC will call Get(HANDLER, "HandledChannels")

Simon McVittie simon.mcvittie at collabora.co.uk
Mon May 25 09:00:09 PDT 2009


Previously, we asserted that it would be called. Now, we allow it to be
called, and return the right thing, but don't fail if this doesn't happen.

This means we no longer have precise control over the order of events in
dispatcher/create-at-startup.py, so we can't assert that ObserveChannels
for the request and the incoming channel are called in the right order.
Temporarily disable that assertion.
---
 test/twisted/Makefile.am                           |    1 -
 .../crash-recovery/client-crash-during-recovery.py |  109 --------------------
 test/twisted/crash-recovery/crash-recovery.py      |   10 --
 test/twisted/dispatcher/already-has-channel.py     |   17 ---
 test/twisted/dispatcher/already-has-obsolete.py    |   17 ---
 test/twisted/dispatcher/create-at-startup.py       |   16 +--
 test/twisted/mctest.py                             |    6 +
 7 files changed, 12 insertions(+), 164 deletions(-)
 delete mode 100644 test/twisted/crash-recovery/client-crash-during-recovery.py

diff --git a/test/twisted/Makefile.am b/test/twisted/Makefile.am
index bf85b07..7320a83 100644
--- a/test/twisted/Makefile.am
+++ b/test/twisted/Makefile.am
@@ -33,7 +33,6 @@ TWISTED_BASIC_TESTS = \
 TWISTED_SEPARATE_TESTS = \
 	account-manager/auto-connect.py \
 	crash-recovery/crash-recovery.py \
-	crash-recovery/client-crash-during-recovery.py \
 	dispatcher/create-at-startup.py
 
 # A demo dispatcher plugin
diff --git a/test/twisted/crash-recovery/client-crash-during-recovery.py b/test/twisted/crash-recovery/client-crash-during-recovery.py
deleted file mode 100644
index 8fdc36b..0000000
--- a/test/twisted/crash-recovery/client-crash-during-recovery.py
+++ /dev/null
@@ -1,109 +0,0 @@
-"""Regression test for a client crashing while recovering from an MC crash.
-"""
-
-import os
-
-import dbus
-import dbus.service
-
-from servicetest import EventPattern, call_async, sync_dbus
-from mctest import exec_test, SimulatedConnection, SimulatedClient, \
-        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
-        expect_client_setup, make_mc
-import constants as cs
-
-def preseed():
-    accounts_dir = os.environ['MC_ACCOUNT_DIR']
-
-    accounts_cfg = open(accounts_dir + '/accounts.cfg', 'w')
-
-    accounts_cfg.write("""# Telepathy accounts
-[fakecm/fakeprotocol/jc_2edenton_40unatco_2eint]
-manager=fakecm
-protocol=fakeprotocol
-DisplayName=Work account
-NormalizedName=jc.denton at unatco.int
-param-account=jc.denton at unatco.int
-param-password=ionstorm
-Enabled=1
-""")
-
-    accounts_cfg.close()
-
-    account_connections_file = open(accounts_dir + '/.mc_connections', 'w')
-
-    account_connections_file.write("%s\t%s\t%s\n" %
-            (cs.tp_path_prefix + '/Connection/fakecm/fakeprotocol/jc',
-                cs.tp_name_prefix + '.Connection.fakecm.fakeprotocol.jc',
-                'fakecm/fakeprotocol/jc_2edenton_40unatco_2eint'))
-
-def test(q, bus, unused):
-    text_fixed_properties = dbus.Dictionary({
-        cs.CHANNEL + '.TargetHandleType': cs.HT_CONTACT,
-        cs.CHANNEL + '.ChannelType': cs.CHANNEL_TYPE_TEXT,
-        }, signature='sv')
-
-    conn = SimulatedConnection(q, bus, 'fakecm', 'fakeprotocol',
-            'jc', 'jc.denton at unatco.int')
-    conn.StatusChanged(cs.CONN_STATUS_CONNECTED, 0)
-
-    unhandled_properties = dbus.Dictionary(text_fixed_properties, signature='sv')
-    unhandled_properties[cs.CHANNEL + '.Interfaces'] = dbus.Array(signature='s')
-    unhandled_properties[cs.CHANNEL + '.TargetID'] = 'anna.navarre at unatco.int'
-    unhandled_properties[cs.CHANNEL + '.TargetHandle'] = \
-            dbus.UInt32(conn.ensure_handle(cs.HT_CONTACT, 'anna.navarre at unatco.int'))
-    unhandled_properties[cs.CHANNEL + '.InitiatorHandle'] = dbus.UInt32(conn.self_handle)
-    unhandled_properties[cs.CHANNEL + '.InitiatorID'] = conn.self_ident
-    unhandled_properties[cs.CHANNEL + '.Requested'] = True
-    unhandled_chan = SimulatedChannel(conn, unhandled_properties)
-    unhandled_chan.announce()
-
-    bus_name = '.'.join([cs.tp_name_prefix, 'Client.CrashMe'])
-    bus_name_ref = dbus.service.BusName(bus_name, bus)
-    object_path = '/' + bus_name.replace('.', '/')
-
-    # service-activate MC
-    mc = make_mc(bus, q.append)
-
-    e = q.expect('dbus-method-call',
-            interface=cs.PROPERTIES_IFACE, method='Get',
-            path=object_path,
-            args=[cs.CLIENT, 'Interfaces'],
-            handled=False)
-    q.dbus_return(e.message, dbus.Array([cs.HANDLER], signature='s'),
-            signature='v')
-
-    e = q.expect('dbus-method-call',
-            interface=cs.PROPERTIES_IFACE, method='GetAll',
-            path=object_path,
-            args=[cs.HANDLER],
-            handled=False)
-
-    q.dbus_return(e.message,
-            dbus.Dictionary({
-                'HandlerChannelFilter': text_fixed_properties,
-                'BypassApproval': True,
-                }, signature='sv'),
-            signature='a{sv}')
-
-    # FIXME: in an ideal world, MC would use its call to GetAll to pre-load
-    # this property anyway
-    e = q.expect('dbus-method-call',
-            args=[cs.HANDLER, 'HandledChannels'],
-            path=object_path,
-            handled=False,
-            interface=cs.PROPERTIES_IFACE,
-            method='Get')
-    # Oops! This would crash earlier versions of MC
-    del bus_name_ref
-    q.dbus_raise(e.message, cs.DBUS_ERROR_NO_REPLY, 'I crashed')
-
-    # Well, there are no clients any more... so nobody can possibly
-    # handle this channel. MC closes it.
-    q.expect('dbus-method-call',
-            path=unhandled_chan.object_path,
-            method='Close')
-
-if __name__ == '__main__':
-    preseed()
-    exec_test(test, {}, preload_mc=False)
diff --git a/test/twisted/crash-recovery/crash-recovery.py b/test/twisted/crash-recovery/crash-recovery.py
index 412f0ae..e8b389c 100644
--- a/test/twisted/crash-recovery/crash-recovery.py
+++ b/test/twisted/crash-recovery/crash-recovery.py
@@ -77,16 +77,6 @@ def test(q, bus, unused):
     # service-activate MC
     mc = make_mc(bus, q.append)
 
-    e = q.expect('dbus-method-call',
-            args=[cs.HANDLER, 'HandledChannels'],
-            path=client.object_path,
-            handled=False,
-            interface=cs.PROPERTIES_IFACE,
-            method='Get')
-    # Empathy is handling one of the channels
-    q.dbus_return(e.message, dbus.Array([handled_chan.object_path],
-        signature='o'), signature='v')
-
     # we're told about the other channel as an observer...
     e = q.expect('dbus-method-call',
             path=client.object_path,
diff --git a/test/twisted/dispatcher/already-has-channel.py b/test/twisted/dispatcher/already-has-channel.py
index 0381c3a..0983de8 100644
--- a/test/twisted/dispatcher/already-has-channel.py
+++ b/test/twisted/dispatcher/already-has-channel.py
@@ -96,23 +96,6 @@ def test(q, bus, mc):
                 path=conn.object_path, handled=True),
             )
 
-    # MC asks the clients whether they know anything about this channel
-    e, k = q.expect_many(
-            EventPattern('dbus-method-call',
-                path=empathy.object_path,
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandledChannels'],
-                handled=False),
-            EventPattern('dbus-method-call',
-                path=kopete.object_path,
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandledChannels'],
-                handled=False),
-            )
-    # they don't
-    q.dbus_return(e.message, dbus.Array([], signature='o'), signature='v')
-    q.dbus_return(k.message, dbus.Array([], signature='o'), signature='v')
-
     # A channel dispatch operation is created for the channel we already had
 
     e = q.expect('dbus-signal',
diff --git a/test/twisted/dispatcher/already-has-obsolete.py b/test/twisted/dispatcher/already-has-obsolete.py
index a7a0996..fefefe1 100644
--- a/test/twisted/dispatcher/already-has-obsolete.py
+++ b/test/twisted/dispatcher/already-has-obsolete.py
@@ -93,23 +93,6 @@ def test(q, bus, mc):
             interface=cs.CONN, method='ListChannels', args=[],
             path=conn.object_path, handled=True)
 
-    # MC asks the clients whether they know anything about this channel
-    e, k = q.expect_many(
-            EventPattern('dbus-method-call',
-                path=empathy.object_path,
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandledChannels'],
-                handled=False),
-            EventPattern('dbus-method-call',
-                path=kopete.object_path,
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandledChannels'],
-                handled=False),
-            )
-    # they don't
-    q.dbus_return(e.message, dbus.Array([], signature='o'), signature='v')
-    q.dbus_return(k.message, dbus.Array([], signature='o'), signature='v')
-
     # A channel dispatch operation is created for the channel we already had
 
     e = q.expect('dbus-signal',
diff --git a/test/twisted/dispatcher/create-at-startup.py b/test/twisted/dispatcher/create-at-startup.py
index 5808665..af7806b 100644
--- a/test/twisted/dispatcher/create-at-startup.py
+++ b/test/twisted/dispatcher/create-at-startup.py
@@ -132,7 +132,7 @@ def test(q, bus, unused):
 
     # Now that the dispatcher is ready to go, we start looking for channels,
     # and also make the actual request
-    _, cm_request_call, get_handled_channels_call = q.expect_many(
+    _, cm_request_call = q.expect_many(
             EventPattern('dbus-method-call',
                 interface=cs.PROPERTIES_IFACE, method='GetAll',
                 args=[cs.CONN_IFACE_REQUESTS],
@@ -140,16 +140,7 @@ def test(q, bus, unused):
             EventPattern('dbus-method-call',
                 interface=cs.CONN_IFACE_REQUESTS, method='CreateChannel',
                 path=conn.object_path, args=[request], handled=False),
-            EventPattern('dbus-method-call',
-                path=client.object_path,
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandledChannels'],
-                handled=False),
             )
-    # FIXME: this Get(HandledChannels) could be done implicitly by the GetAll
-    # during basic Handler setup, if MC was refactored more
-    q.dbus_return(get_handled_channels_call.message, dbus.Array(signature='o'),
-            signature='v')
 
     # Time passes. A channel is returned.
 
@@ -177,6 +168,11 @@ def test(q, bus, unused):
             interface=cs.OBSERVER, method='ObserveChannels',
             handled=False)
 
+    # ... but currently there's no guarantee that they'll be in the right
+    # order, so swap them if necessary (FIXME: take this out)
+    if a.args[3] == '/':
+        a, e = e, a
+
     assert a.args[0] == account.object_path, a.args
     assert a.args[1] == conn.object_path, a.args
     assert a.args[3] != '/', a.args         # there is a dispatch operation
diff --git a/test/twisted/mctest.py b/test/twisted/mctest.py
index a125e38..5978e8e 100644
--- a/test/twisted/mctest.py
+++ b/test/twisted/mctest.py
@@ -471,6 +471,9 @@ class SimulatedClient(object):
         q.add_dbus_method_impl(self.Get_HandlerChannelFilter,
                 path=self.object_path, interface=cs.PROPERTIES_IFACE,
                 method='Get', args=[cs.HANDLER, 'HandlerChannelFilter'])
+        q.add_dbus_method_impl(self.Get_HandledChannels,
+                path=self.object_path, interface=cs.PROPERTIES_IFACE,
+                method='Get', args=[cs.HANDLER, 'HandledChannels'])
         q.add_dbus_method_impl(self.Get_BypassApproval,
                 path=self.object_path, interface=cs.PROPERTIES_IFACE,
                 method='Get', args=[cs.HANDLER, 'BypassApproval'])
@@ -529,6 +532,9 @@ class SimulatedClient(object):
             },
                 signature='a{sv}')
 
+    def Get_HandledChannels(self, e):
+        self.q.dbus_return(e.message, self.handled_channels, signature='v')
+
     def Get_HandlerChannelFilter(self, e):
         assert self.handle
         self.q.dbus_return(e.message, self.handle, signature='v')
-- 
1.5.6.5




More information about the telepathy-commits mailing list