[telepathy-mission-control/master] account-manager/create-with-properties.py: new test for the Creation interface

Simon McVittie simon.mcvittie at collabora.co.uk
Mon May 4 07:27:59 PDT 2009


---
 test/twisted/Makefile.am                           |    1 +
 .../account-manager/create-with-properties.py      |   88 ++++++++++++++++++++
 2 files changed, 89 insertions(+), 0 deletions(-)
 create mode 100644 test/twisted/account-manager/create-with-properties.py

diff --git a/test/twisted/Makefile.am b/test/twisted/Makefile.am
index 19e0477..e9091dd 100644
--- a/test/twisted/Makefile.am
+++ b/test/twisted/Makefile.am
@@ -3,6 +3,7 @@ TWISTED_TESTS =
 TWISTED_BASIC_TESTS = \
 	account-bad-cm.py \
 	account-manager/auto-away.py \
+	account-manager/create-with-properties.py \
 	account-manager/reconnect.py \
 	account-requests/cancel.py \
 	account-requests/create-text.py \
diff --git a/test/twisted/account-manager/create-with-properties.py b/test/twisted/account-manager/create-with-properties.py
new file mode 100644
index 0000000..b42ebbc
--- /dev/null
+++ b/test/twisted/account-manager/create-with-properties.py
@@ -0,0 +1,88 @@
+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):
+    # Get the AccountManager interface
+    account_manager = bus.get_object(cs.AM, cs.AM_PATH)
+    account_manager_iface = dbus.Interface(account_manager, cs.AM)
+
+    # Introspect AccountManager for debugging purpose
+    account_manager_introspected = account_manager.Introspect(
+            dbus_interface=cs.INTROSPECTABLE_IFACE)
+    #print account_manager_introspected
+
+    # Check AccountManager has D-Bus property interface
+    properties = account_manager.GetAll(cs.AM,
+            dbus_interface=cs.PROPERTIES_IFACE)
+    assert properties is not None
+    assert properties.get('ValidAccounts') == [], \
+        properties.get('ValidAccounts')
+    assert properties.get('InvalidAccounts') == [], \
+        properties.get('InvalidAccounts')
+    interfaces = properties.get('Interfaces')
+
+    # assert that current functionality exists
+    assert cs.AM_IFACE_CREATION_DRAFT in interfaces, interfaces
+    assert cs.AM_IFACE_NOKIA_QUERY in interfaces, interfaces
+
+    params = dbus.Dictionary({"account": "someguy at example.com",
+        "password": "secrecy"}, signature='sv')
+
+    cm_name_ref = dbus.service.BusName(cs.tp_name_prefix +
+            '.ConnectionManager.fakecm', bus=bus)
+    account_manager = bus.get_object(cs.AM, cs.AM_PATH)
+    creation_iface = dbus.Interface(account_manager,
+            cs.AM_IFACE_CREATION_DRAFT)
+
+    creation_properties = dbus.Dictionary({
+        cs.ACCOUNT + '.Enabled': True,
+        cs.ACCOUNT + '.AutomaticPresence': dbus.Struct((
+            dbus.UInt32(cs.PRESENCE_TYPE_BUSY),
+            'busy', 'Exploding'), signature='uss'),
+        }, signature='sv')
+
+    call_async(q, creation_iface, 'CreateAccount',
+            'fakecm',
+            'fakeprotocol',
+            'fakeaccount',
+            params,
+            creation_properties)
+
+    # The spec has no order guarantee here.
+    # FIXME: MC ought to also introspect the CM and find out that the params
+    # are in fact sufficient
+
+    a_signal, am_signal, ret = q.expect_many(
+            EventPattern('dbus-signal',
+                signal='AccountPropertyChanged', interface=cs.ACCOUNT,
+                predicate=(lambda e: 'Valid' in e.args[0])),
+            EventPattern('dbus-signal', path=cs.AM_PATH,
+                signal='AccountValidityChanged', interface=cs.AM),
+            EventPattern('dbus-return', method='CreateAccount'),
+            )
+    account_path = ret.value[0]
+    assert am_signal.args == [account_path, True], am_signal.args
+    assert a_signal.args[0]['Valid'] == True, a_signal.args
+
+    assert account_path is not None
+
+    account = bus.get_object(
+        cs.tp_name_prefix + '.AccountManager',
+        account_path)
+    account_props = dbus.Interface(account, cs.PROPERTIES_IFACE)
+
+    properties = account_props.GetAll(cs.ACCOUNT)
+    assert properties.get('AutomaticPresence') == (cs.PRESENCE_TYPE_BUSY,
+            'busy', 'Exploding'), \
+        properties.get('AutomaticPresence')
+
+    # FIXME: doing the same thing with RequestedPresence doesn't work
+
+
+if __name__ == '__main__':
+    exec_test(test, {})
-- 
1.5.6.5




More information about the telepathy-commits mailing list