[telepathy-mission-control/master] Update docs, tests, util for CreateAccount taking a Properties argument
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu May 7 09:06:02 PDT 2009
In the process, duplicate the existing account-creation-with-properties
test (using the Creation interface) as old-create-with-properties.py,
and make create-with-properties.py use the core Account interface instead.
---
.../libmcclient/tmpl/mc-account-manager.sgml | 1 +
test/twisted/Makefile.am | 1 +
test/twisted/account-bad-cm.py | 3 +
.../account-manager/create-with-properties.py | 5 +-
.../account-manager/old-create-with-properties.py | 131 ++++++++++++++++++++
test/twisted/mctest.py | 1 +
util/mc-account-convert.c | 4 +
7 files changed, 143 insertions(+), 3 deletions(-)
create mode 100644 test/twisted/account-manager/old-create-with-properties.py
diff --git a/doc/reference/libmcclient/tmpl/mc-account-manager.sgml b/doc/reference/libmcclient/tmpl/mc-account-manager.sgml
index c3dc937..c7ddf12 100644
--- a/doc/reference/libmcclient/tmpl/mc-account-manager.sgml
+++ b/doc/reference/libmcclient/tmpl/mc-account-manager.sgml
@@ -217,6 +217,7 @@ mc-account-manager
@in_Protocol:
@in_Display_Name:
@in_Parameters:
+ at in_Properties:
@callback:
@user_data:
@destroy:
diff --git a/test/twisted/Makefile.am b/test/twisted/Makefile.am
index 20e1153..f594681 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/old-create-with-properties.py \
account-manager/reconnect.py \
account-manager/update-parameters.py \
account-requests/cancel.py \
diff --git a/test/twisted/account-bad-cm.py b/test/twisted/account-bad-cm.py
index d41a5e1..2e2af18 100644
--- a/test/twisted/account-bad-cm.py
+++ b/test/twisted/account-bad-cm.py
@@ -28,6 +28,7 @@ def test(q, bus, mc):
'fakeprotocol', # Protocol
'fakeaccount', #Display_Name
params, # Parameters
+ {}, # Properties
)
q.expect('dbus-error', method='CreateAccount')
@@ -40,6 +41,7 @@ def test(q, bus, mc):
'nonexistent-protocol', # Protocol
'fakeaccount', #Display_Name
params, # Parameters
+ {}, # Properties
)
q.expect('dbus-error', method='CreateAccount')
@@ -52,6 +54,7 @@ def test(q, bus, mc):
'fakeprotocol', # Protocol
'fakeaccount', #Display_Name
params, # Parameters
+ {}, # Properties
)
q.expect('dbus-error', method='CreateAccount')
diff --git a/test/twisted/account-manager/create-with-properties.py b/test/twisted/account-manager/create-with-properties.py
index 19763a0..16035be 100644
--- a/test/twisted/account-manager/create-with-properties.py
+++ b/test/twisted/account-manager/create-with-properties.py
@@ -50,8 +50,7 @@ def test(q, bus, mc):
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)
+ am_iface = dbus.Interface(account_manager, cs.AM)
creation_properties = dbus.Dictionary({
cs.ACCOUNT + '.Enabled': True,
@@ -70,7 +69,7 @@ def test(q, bus, mc):
dbus.Dictionary({ 'has-quad-damage': ':y' }, signature='ss'),
}, signature='sv')
- call_async(q, creation_iface, 'CreateAccount',
+ call_async(q, am_iface, 'CreateAccount',
'fakecm',
'fakeprotocol',
'fakeaccount',
diff --git a/test/twisted/account-manager/old-create-with-properties.py b/test/twisted/account-manager/old-create-with-properties.py
new file mode 100644
index 0000000..19763a0
--- /dev/null
+++ b/test/twisted/account-manager/old-create-with-properties.py
@@ -0,0 +1,131 @@
+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')
+ supported = properties.get('SupportedAccountProperties')
+
+ # assert that current functionality exists
+ assert cs.AM_IFACE_CREATION_DRAFT in interfaces, interfaces
+ assert cs.AM_IFACE_NOKIA_QUERY in interfaces, interfaces
+
+ assert (cs.ACCOUNT + '.AutomaticPresence') in supported
+ assert (cs.ACCOUNT + '.Enabled') in supported
+ assert (cs.ACCOUNT + '.Icon') in supported
+ assert (cs.ACCOUNT + '.Nickname') in supported
+ assert (cs.ACCOUNT + '.ConnectAutomatically') in supported
+ assert (cs.ACCOUNT_IFACE_AVATAR + '.Avatar') in supported
+ assert (cs.ACCOUNT_IFACE_NOKIA_COMPAT + '.Profile') in supported
+ assert (cs.ACCOUNT_IFACE_NOKIA_COMPAT + '.SecondaryVCardFields') in supported
+ assert (cs.ACCOUNT_IFACE_NOKIA_CONDITIONS + '.Condition') in supported
+
+ # FIXME: setting RequestedPresence at create time doesn't work yet
+ #assert (cs.ACCOUNT + '.RequestedPresence') in supported
+
+ params = dbus.Dictionary({"account": "anarki 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'),
+ cs.ACCOUNT + '.Icon': 'quake3arena',
+ cs.ACCOUNT + '.Nickname': 'AnArKi',
+ cs.ACCOUNT + '.ConnectAutomatically': True,
+ cs.ACCOUNT_IFACE_AVATAR + '.Avatar': (dbus.ByteArray('foo'),
+ 'image/jpeg'),
+ cs.ACCOUNT_IFACE_NOKIA_COMPAT + '.Profile': 'openarena',
+ cs.ACCOUNT_IFACE_NOKIA_COMPAT + '.SecondaryVCardFields':
+ dbus.Array(['x-ioquake3', 'x-quake3'], signature='s'),
+ cs.ACCOUNT_IFACE_NOKIA_CONDITIONS + '.Condition':
+ dbus.Dictionary({ 'has-quad-damage': ':y' }, signature='ss'),
+ }, 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')
+ assert properties.get('ConnectAutomatically') == True, \
+ properties.get('ConnectAutomatically')
+ assert properties.get('Enabled') == True, \
+ properties.get('Enabled')
+ assert properties.get('Icon') == 'quake3arena', \
+ properties.get('Icon')
+ assert properties.get('Nickname') == 'AnArKi', \
+ properties.get('Nickname')
+
+ properties = account_props.GetAll(cs.ACCOUNT_IFACE_AVATAR)
+ assert properties.get('Avatar') == ([ord('f'), ord('o'), ord('o')],
+ 'image/jpeg')
+
+ properties = account_props.GetAll(cs.ACCOUNT_IFACE_NOKIA_COMPAT)
+ assert properties.get('Profile') == 'openarena'
+ assert sorted(properties.get('SecondaryVCardFields')) == \
+ ['x-ioquake3', 'x-quake3']
+
+ properties = account_props.GetAll(cs.ACCOUNT_IFACE_NOKIA_CONDITIONS)
+ assert properties.get('Condition') == {
+ 'has-quad-damage': ':y',
+ }
+
+if __name__ == '__main__':
+ exec_test(test, {})
diff --git a/test/twisted/mctest.py b/test/twisted/mctest.py
index 36f4bf5..471a876 100644
--- a/test/twisted/mctest.py
+++ b/test/twisted/mctest.py
@@ -446,6 +446,7 @@ def create_fakecm_account(q, bus, mc, params):
'fakeprotocol', # Protocol
'fakeaccount', #Display_Name
params, # Parameters
+ {}, # Properties
)
# The spec has no order guarantee here.
# FIXME: MC ought to also introspect the CM and find out that the params
diff --git a/util/mc-account-convert.c b/util/mc-account-convert.c
index 9a4dc24..8e8ca8d 100644
--- a/util/mc-account-convert.c
+++ b/util/mc-account-convert.c
@@ -579,16 +579,20 @@ static gboolean
write_account (McAccountManager *am, AccountInfo *ai)
{
TpProxyPendingCall *call;
+ GHashTable *empty;
+ empty = g_hash_table_new (g_str_hash, g_str_equal);
call = mc_cli_account_manager_call_create_account (am, -1,
ai->manager,
ai->protocol,
ai->display_name,
ai->parameters,
+ empty,
create_account_cb,
ai,
NULL,
NULL);
+ g_hash_table_unref (empty);
if (!call) return FALSE;
return TRUE;
--
1.5.6.5
More information about the telepathy-commits
mailing list