[telepathy-mission-control/master] account-manager/nickname.py: Add a regression test for the Nickname property

Simon McVittie simon.mcvittie at collabora.co.uk
Wed May 20 09:32:26 PDT 2009


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

diff --git a/test/twisted/Makefile.am b/test/twisted/Makefile.am
index d58fb28..0551cee 100644
--- a/test/twisted/Makefile.am
+++ b/test/twisted/Makefile.am
@@ -4,6 +4,7 @@ TWISTED_BASIC_TESTS = \
 	account-bad-cm.py \
 	account-manager/auto-away.py \
 	account-manager/create-with-properties.py \
+	account-manager/nickname.py \
 	account-manager/old-create-with-properties.py \
 	account-manager/reconnect.py \
 	account-manager/update-parameters.py \
diff --git a/test/twisted/account-manager/nickname.py b/test/twisted/account-manager/nickname.py
new file mode 100644
index 0000000..476a02c
--- /dev/null
+++ b/test/twisted/account-manager/nickname.py
@@ -0,0 +1,59 @@
+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, enable_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": "wjt 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, 'Nickname',
+            'resiak')
+    q.expect_many(
+        EventPattern('dbus-signal',
+            path=account.object_path,
+            signal='AccountPropertyChanged',
+            interface=cs.ACCOUNT,
+            args=[{'Nickname': 'resiak'}]),
+        EventPattern('dbus-return', method='Set'),
+        )
+    assert account_props.Get(cs.ACCOUNT, 'Nickname') == 'resiak'
+
+    # OK, let's go online
+    conn, e = enable_fakecm_account(q, bus, mc, account, params,
+            has_aliasing=True,
+            expect_after_connect=[
+                EventPattern('dbus-method-call',
+                    interface=cs.CONN_IFACE_ALIASING, method='SetAliases',
+                    handled=False),
+                ])
+
+    assert e.args[0] == { conn.self_handle: 'resiak' }
+    q.dbus_return(e.message, signature='')
+
+    # Change alias after going online
+    call_async(q, account_props, 'Set', cs.ACCOUNT, 'Nickname',
+            'Will Thomspon')
+
+    e = q.expect('dbus-method-call',
+        interface=cs.CONN_IFACE_ALIASING, method='SetAliases',
+        args=[{ conn.self_handle: 'Will Thomspon' }],
+        handled=False)
+
+    # Set returns immediately; the change happens asynchronously
+    q.expect('dbus-return', method='Set')
+
+    q.dbus_return(e.message, signature='')
+
+if __name__ == '__main__':
+    exec_test(test, {})
-- 
1.5.6.5




More information about the telepathy-commits mailing list