diff options
author | Alberto Mardegan <alberto.mardegan@nokia.com> | 2009-04-01 09:48:27 +0300 |
---|---|---|
committer | Alberto Mardegan <alberto.mardegan@nokia.com> | 2009-04-01 09:48:27 +0300 |
commit | 8cd1ae91b3b8014bec14b301a126baabcabcf0c8 (patch) | |
tree | f3adb0ddbb3272e9fa922dc9b0414a2016b99e92 /test/twisted/test-account.py | |
parent | 04690c72d5f29fba232a9ca8cb0d135ee7eb1729 (diff) | |
parent | ee8f3e731a015b390e8914f95f48c491f3ac6248 (diff) |
Merge branch 'master' of git+ssh://git.collabora.co.uk/git/telepathy-mission-control5.0.beta64
Diffstat (limited to 'test/twisted/test-account.py')
-rw-r--r-- | test/twisted/test-account.py | 122 |
1 files changed, 82 insertions, 40 deletions
diff --git a/test/twisted/test-account.py b/test/twisted/test-account.py index c9be1f2e..a49c0b74 100644 --- a/test/twisted/test-account.py +++ b/test/twisted/test-account.py @@ -1,8 +1,10 @@ import dbus -from servicetest import EventPattern, tp_name_prefix, tp_path_prefix +from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \ + call_async from fakecm import start_fake_connection_manager from mctest import exec_test +import constants as cs FakeCM_bus_name = "com.example.FakeCM" ConnectionManager_object_path = "/com/example/FakeCM/ConnectionManager" @@ -10,46 +12,51 @@ ConnectionManager_object_path = "/com/example/FakeCM/ConnectionManager" def test(q, bus, mc): # Get the AccountManager interface - account_manager = bus.get_object( - tp_name_prefix + '.AccountManager', - tp_path_prefix + '/AccountManager') - account_manager_iface = dbus.Interface(account_manager, - 'org.freedesktop.Telepathy.AccountManager') + 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='org.freedesktop.DBus.Introspectable') + dbus_interface=cs.INTROSPECTABLE_IFACE) #print account_manager_introspected # Check AccountManager has D-Bus property interface - properties = account_manager.GetAll( - 'org.freedesktop.Telepathy.AccountManager', - dbus_interface='org.freedesktop.DBus.Properties') + properties = account_manager.GetAll(cs.AM, + dbus_interface=cs.PROPERTIES_IFACE) assert properties is not None - assert properties.get('Interfaces') == [ - 'org.freedesktop.Telepathy.AccountManager', - 'com.nokia.AccountManager.Interface.Query', - 'org.freedesktop.Telepathy.AccountManager.Interface.Creation.DRAFT' - ], properties.get('Interfaces') 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 # Create an account - params = dbus.Dictionary({"nickname": "fakenick"}, signature='sv') - account_path = account_manager_iface.CreateAccount( + params = dbus.Dictionary({"account": "someguy@example.com", + "password": "secrecy"}, signature='sv') + call_async(q, account_manager_iface, 'CreateAccount', 'fakecm', # Connection_Manager 'fakeprotocol', # Protocol 'fakeaccount', #Display_Name params, # Parameters ) + # the spec has no order guarantee here + signal, ret = q.expect_many( + EventPattern('dbus-signal', path=cs.AM_PATH, + signal='AccountValidityChanged', interface=cs.AM), + EventPattern('dbus-return', method='CreateAccount'), + ) + account_path = ret.value[0] + assert signal.args == [account_path, True], signal.args + assert account_path is not None # Check the account is correctly created - properties = account_manager.GetAll( - 'org.freedesktop.Telepathy.AccountManager', - dbus_interface='org.freedesktop.DBus.Properties') + properties = account_manager.GetAll(cs.AM, + dbus_interface=cs.PROPERTIES_IFACE) assert properties is not None assert properties.get('ValidAccounts') == [account_path], properties account_path = properties['ValidAccounts'][0] @@ -60,26 +67,17 @@ def test(q, bus, mc): account = bus.get_object( tp_name_prefix + '.AccountManager', account_path) - account_iface = dbus.Interface(account, - 'org.freedesktop.Telepathy.Account') + account_iface = dbus.Interface(account, cs.ACCOUNT) + account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) # Introspect Account for debugging purpose account_introspected = account.Introspect( - dbus_interface='org.freedesktop.DBus.Introspectable') + dbus_interface=cs.INTROSPECTABLE_IFACE) #print account_introspected # Check Account has D-Bus property interface - properties = account.GetAll( - 'org.freedesktop.Telepathy.Account', - dbus_interface='org.freedesktop.DBus.Properties') + properties = account_props.GetAll(cs.ACCOUNT) assert properties is not None - assert 'org.freedesktop.Telepathy.Account' \ - in properties.get('Interfaces'), properties.get('Interfaces') - assert 'org.freedesktop.Telepathy.Account.Interface.Avatar' \ - in properties.get('Interfaces'), properties.get('Interfaces') - assert 'org.freedesktop.Telepathy.Account.Interface.Compat' \ - in properties.get('Interfaces'), properties.get('Interfaces') - assert 'com.nokia.Account.Interface.Conditions' \ - in properties.get('Interfaces'), properties.get('Interfaces') + assert properties.get('DisplayName') == 'fakeaccount', \ properties.get('DisplayName') assert properties.get('Icon') == '', properties.get('Icon') @@ -91,27 +89,71 @@ def test(q, bus, mc): assert properties.get('NormalizedName') == '', \ properties.get('NormalizedName') + interfaces = properties.get('Interfaces') + assert cs.ACCOUNT_IFACE_AVATAR in interfaces, interfaces + assert cs.ACCOUNT_IFACE_NOKIA_COMPAT in interfaces, interfaces + assert cs.ACCOUNT_IFACE_NOKIA_CONDITIONS in interfaces, interfaces + + # sanity check + for k in properties: + assert account_props.Get(cs.ACCOUNT, k) == properties[k], k + + # Alter some miscellaneous r/w properties + + call_async(q, account_props, 'Set', cs.ACCOUNT, 'DisplayName', + 'Work account') + q.expect_many( + EventPattern('dbus-signal', + path=account_path, + signal='AccountPropertyChanged', + interface=cs.ACCOUNT, + args=[{'DisplayName': 'Work account'}]), + EventPattern('dbus-return', method='Set'), + ) + assert account_props.Get(cs.ACCOUNT, 'DisplayName') == 'Work account' + + call_async(q, account_props, 'Set', cs.ACCOUNT, 'Icon', 'im-jabber') + q.expect_many( + EventPattern('dbus-signal', + path=account_path, + signal='AccountPropertyChanged', + interface=cs.ACCOUNT, + args=[{'Icon': 'im-jabber'}]), + EventPattern('dbus-return', method='Set'), + ) + assert account_props.Get(cs.ACCOUNT, 'Icon') == 'im-jabber' + + call_async(q, account_props, 'Set', cs.ACCOUNT, 'Nickname', 'Joe Bloggs') + q.expect_many( + EventPattern('dbus-signal', + path=account_path, + signal='AccountPropertyChanged', + interface=cs.ACCOUNT, + args=[{'Nickname': 'Joe Bloggs'}]), + EventPattern('dbus-return', method='Set'), + ) + assert account_props.Get(cs.ACCOUNT, 'Nickname') == 'Joe Bloggs' + # Delete the account assert account_iface.Remove() is None account_event, account_manager_event = q.expect_many( EventPattern('dbus-signal', path=account_path, signal='Removed', - interface='org.freedesktop.Telepathy.Account', + interface=cs.ACCOUNT, args=[] ), EventPattern('dbus-signal', - path=tp_path_prefix + '/AccountManager', + path=cs.AM_PATH, signal='AccountRemoved', - interface='org.freedesktop.Telepathy.AccountManager', + interface=cs.AM, args=[account_path] ), ) # Check the account is correctly deleted - properties = account_manager.GetAll( - 'org.freedesktop.Telepathy.AccountManager', - dbus_interface='org.freedesktop.DBus.Properties') + properties = account_manager.GetAll(cs.AM, + dbus_interface=cs.PROPERTIES_IFACE) assert properties is not None assert properties.get('ValidAccounts') == [], properties assert properties.get('InvalidAccounts') == [], properties |