[telepathy-mission-control/master] Add a regression test for basic recovery from disconnection

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Jun 3 09:35:21 PDT 2009


---
 test/twisted/Makefile.am                           |    1 +
 .../account-manager/recover-from-disconnect.py     |   98 ++++++++++++++++++++
 2 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100644 test/twisted/account-manager/recover-from-disconnect.py

diff --git a/test/twisted/Makefile.am b/test/twisted/Makefile.am
index 8af1d01..eef7f44 100644
--- a/test/twisted/Makefile.am
+++ b/test/twisted/Makefile.am
@@ -9,6 +9,7 @@ TWISTED_BASIC_TESTS = \
 	account-manager/old-create-with-properties.py \
 	account-manager/presence.py \
 	account-manager/reconnect.py \
+	account-manager/recover-from-disconnect.py \
 	account-manager/update-parameters.py \
 	account-requests/cancel.py \
 	account-requests/create-text.py \
diff --git a/test/twisted/account-manager/recover-from-disconnect.py b/test/twisted/account-manager/recover-from-disconnect.py
new file mode 100644
index 0000000..c79d17b
--- /dev/null
+++ b/test/twisted/account-manager/recover-from-disconnect.py
@@ -0,0 +1,98 @@
+import dbus
+import dbus.service
+
+from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
+        call_async, sync_dbus
+from mctest import exec_test, SimulatedConnection, create_fakecm_account,\
+        SimulatedChannel
+import constants as cs
+
+def test(q, bus, mc):
+    cm_name_ref = dbus.service.BusName(
+            tp_name_prefix + '.ConnectionManager.fakecm', bus=bus)
+
+    # Create an account
+    params = dbus.Dictionary({"account": "someguy at example.com",
+        "password": "secrecy"}, signature='sv')
+    (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params)
+
+    account_iface = dbus.Interface(account, cs.ACCOUNT)
+    account_props = dbus.Interface(account, cs.PROPERTIES_IFACE)
+
+    call_async(q, account, 'Set', cs.ACCOUNT, 'Enabled', False,
+            dbus_interface=cs.PROPERTIES_IFACE)
+    q.expect('dbus-return', method='Set')
+
+    # Enable the account
+    call_async(q, account, 'Set', cs.ACCOUNT, 'Enabled', True,
+            dbus_interface=cs.PROPERTIES_IFACE)
+
+    # Set online presence
+    presence = dbus.Struct((dbus.UInt32(cs.PRESENCE_TYPE_BUSY), 'busy',
+            'Fixing MC bugs'), signature='uss')
+    call_async(q, account, 'Set', cs.ACCOUNT,
+            'RequestedPresence', presence,
+            dbus_interface=cs.PROPERTIES_IFACE)
+
+    e = q.expect('dbus-method-call', method='RequestConnection',
+            args=['fakeprotocol', params],
+            destination=tp_name_prefix + '.ConnectionManager.fakecm',
+            path=tp_path_prefix + '/ConnectionManager/fakecm',
+            interface=tp_name_prefix + '.ConnectionManager',
+            handled=False)
+
+    conn = SimulatedConnection(q, bus, 'fakecm', 'fakeprotocol', '_',
+            'myself')
+
+    q.dbus_return(e.message, conn.bus_name, conn.object_path, signature='so')
+
+    # MC calls GetStatus (maybe) and then Connect
+
+    q.expect('dbus-method-call', method='Connect',
+            path=conn.object_path, handled=True)
+
+    # Connect succeeds
+    conn.StatusChanged(cs.CONN_STATUS_CONNECTED, cs.CONN_STATUS_REASON_NONE)
+
+    q.expect_many(
+            EventPattern('dbus-method-call',
+                interface=cs.PROPERTIES_IFACE, method='GetAll',
+                args=[cs.CONN_IFACE_REQUESTS],
+                path=conn.object_path, handled=True),
+            )
+
+    # Connection falls over for a miscellaneous reason
+    conn.StatusChanged(cs.CONN_STATUS_DISCONNECTED,
+            cs.CONN_STATUS_REASON_NETWORK_ERROR)
+
+    # MC reconnects
+
+    e = q.expect('dbus-method-call', method='RequestConnection',
+            args=['fakeprotocol', params],
+            destination=tp_name_prefix + '.ConnectionManager.fakecm',
+            path=tp_path_prefix + '/ConnectionManager/fakecm',
+            interface=tp_name_prefix + '.ConnectionManager',
+            handled=False)
+
+    conn = SimulatedConnection(q, bus, 'fakecm', 'fakeprotocol', '_',
+            'myself')
+
+    q.dbus_return(e.message, conn.bus_name, conn.object_path, signature='so')
+
+    # MC calls GetStatus (maybe) and then Connect
+
+    q.expect('dbus-method-call', method='Connect',
+            path=conn.object_path, handled=True)
+
+    # Connect succeeds
+    conn.StatusChanged(cs.CONN_STATUS_CONNECTED, cs.CONN_STATUS_REASON_NONE)
+
+    q.expect_many(
+            EventPattern('dbus-method-call',
+                interface=cs.PROPERTIES_IFACE, method='GetAll',
+                args=[cs.CONN_IFACE_REQUESTS],
+                path=conn.object_path, handled=True),
+            )
+
+if __name__ == '__main__':
+    exec_test(test, {})
-- 
1.5.6.5




More information about the telepathy-commits mailing list