[telepathy-mission-control/master] account-manager/enable.py: assert that when an account with RequestedPresence online is enabled, it goes online

Simon McVittie simon.mcvittie at collabora.co.uk
Thu Jun 25 08:12:08 PDT 2009


---
 test/twisted/Makefile.am               |    1 +
 test/twisted/account-manager/enable.py |   50 ++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 0 deletions(-)
 create mode 100644 test/twisted/account-manager/enable.py

diff --git a/test/twisted/Makefile.am b/test/twisted/Makefile.am
index a642d83..2e7d2b3 100644
--- a/test/twisted/Makefile.am
+++ b/test/twisted/Makefile.am
@@ -6,6 +6,7 @@ TWISTED_BASIC_TESTS = \
 	account-manager/avatar.py \
 	account-manager/create-auto-connect.py \
 	account-manager/create-with-properties.py \
+	account-manager/enable.py \
 	account-manager/enable-auto-connect.py \
 	account-manager/nickname.py \
 	account-manager/old-create-with-properties.py \
diff --git a/test/twisted/account-manager/enable.py b/test/twisted/account-manager/enable.py
new file mode 100644
index 0000000..2b8a8cf
--- /dev/null
+++ b/test/twisted/account-manager/enable.py
@@ -0,0 +1,50 @@
+import dbus
+import dbus.service
+
+from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
+        call_async
+from mctest import exec_test, create_fakecm_account
+import constants as cs
+
+def test(q, bus, mc):
+    account_manager = bus.get_object(cs.AM, cs.AM_PATH)
+    account_manager_iface = dbus.Interface(account_manager, cs.AM)
+
+    params = dbus.Dictionary({"account": "smcv 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_props, 'Set', cs.ACCOUNT, 'RequestedPresence',
+            (dbus.UInt32(cs.PRESENCE_TYPE_OFFLINE), 'offline', ''))
+    q.expect('dbus-return', method='Set')
+    q.expect('dbus-signal', signal='AccountPropertyChanged',
+            predicate=lambda e:
+                e.args[0].get('RequestedPresence', (None, None, None))[1]
+                    == 'offline')
+
+    call_async(q, account_props, 'Set', cs.ACCOUNT, 'Enabled', False)
+    q.expect('dbus-return', method='Set')
+
+    call_async(q, account_props, 'Set', cs.ACCOUNT, 'ConnectAutomatically',
+            False)
+    q.expect('dbus-return', method='Set')
+
+    call_async(q, account_props, 'Set', cs.ACCOUNT, 'RequestedPresence',
+            (dbus.UInt32(cs.PRESENCE_TYPE_BUSY), 'busy', 'Testing Enabled'))
+    q.expect('dbus-return', method='Set')
+
+    # Go online by setting Enabled
+    call_async(q, account_props, 'Set', cs.ACCOUNT, 'Enabled', True)
+
+    e = q.expect('dbus-method-call', method='RequestConnection',
+            args=['fakeprotocol', params],
+            destination=cs.tp_name_prefix + '.ConnectionManager.fakecm',
+            path=cs.tp_path_prefix + '/ConnectionManager/fakecm',
+            interface=cs.tp_name_prefix + '.ConnectionManager',
+            handled=False)
+
+if __name__ == '__main__':
+    exec_test(test, {})
-- 
1.5.6.5




More information about the telepathy-commits mailing list