From 78121338e006ffbdf200011672c9a4785b384d1d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 15 Oct 2013 16:16:14 +0100 Subject: [PATCH 1/4] Regression tests: use a simulated CM instead of just holding the bus name We'll need this if we want to call IdentifyAccount. --- tests/twisted/account-manager/account-basics.py | 2 +- tests/twisted/account-manager/auto-connect.py | 9 +- tests/twisted/account-manager/avatar-refresh.py | 8 +- tests/twisted/account-manager/avatar.py | 2 +- tests/twisted/account-manager/connectivity.py | 2 +- tests/twisted/account-manager/crashy-cm.py | 4 +- .../twisted/account-manager/create-auto-connect.py | 2 +- tests/twisted/account-manager/create-twice.py | 5 +- .../account-manager/create-with-properties.py | 5 +- tests/twisted/account-manager/device-idle.py | 2 +- .../twisted/account-manager/enable-auto-connect.py | 2 +- tests/twisted/account-manager/enable.py | 2 +- tests/twisted/account-manager/irc.py | 2 +- tests/twisted/account-manager/make-valid.py | 7 +- tests/twisted/account-manager/nickname.py | 2 +- tests/twisted/account-manager/param-types.py | 8 +- tests/twisted/account-manager/presence.py | 2 +- tests/twisted/account-manager/reconnect.py | 5 +- .../account-manager/recover-from-disconnect.py | 2 +- tests/twisted/account-manager/req-conn-fails.py | 2 +- tests/twisted/account-manager/request-online.py | 5 +- tests/twisted/account-manager/server-drops-us.py | 5 +- tests/twisted/account-manager/service.py | 2 +- tests/twisted/account-manager/update-parameters.py | 5 +- tests/twisted/account-requests/cancel.py | 2 +- tests/twisted/account-requests/create-text.py | 2 +- .../delete-account-during-request.py | 2 +- .../account-storage/default-keyring-storage.py | 2 +- tests/twisted/account-storage/diverted-storage.py | 2 +- tests/twisted/account/addressing.py | 2 +- tests/twisted/capabilities/contact-caps.py | 2 +- tests/twisted/crash-recovery/crash-recovery.py | 2 +- tests/twisted/dispatcher/already-has-channel.py | 2 +- tests/twisted/dispatcher/approver-fails.py | 2 +- tests/twisted/dispatcher/bypass-approval.py | 2 +- tests/twisted/dispatcher/bypass-observers.py | 2 +- tests/twisted/dispatcher/cancel.py | 2 +- tests/twisted/dispatcher/capture-bundle.py | 2 +- tests/twisted/dispatcher/cdo-claim.py | 2 +- tests/twisted/dispatcher/connect-for-request.py | 2 +- tests/twisted/dispatcher/create-at-startup.py | 5 +- .../dispatcher/create-delayed-by-mini-plugin.py | 2 +- tests/twisted/dispatcher/create-handler-fails.py | 2 +- tests/twisted/dispatcher/create-hints.py | 2 +- .../dispatcher/create-no-preferred-handler.py | 2 +- .../dispatcher/create-rejected-by-mini-plugin.py | 2 +- tests/twisted/dispatcher/create-text.py | 2 +- .../twisted/dispatcher/created-behind-our-back.py | 2 +- tests/twisted/dispatcher/delay-approvers.py | 2 +- .../dispatcher/delay-then-call-handle-with.py | 2 +- .../dispatcher/delay-then-dont-call-approvers.py | 2 +- tests/twisted/dispatcher/dispatch-activatable.py | 2 +- .../dispatcher/dispatch-before-connected.py | 2 +- .../dispatcher/dispatch-delayed-by-mini-plugin.py | 2 +- tests/twisted/dispatcher/dispatch-obsolete.py | 2 +- .../dispatcher/dispatch-rejected-by-mini-plugin.py | 2 +- tests/twisted/dispatcher/dispatch-text.py | 2 +- tests/twisted/dispatcher/ensure-and-redispatch.py | 2 +- tests/twisted/dispatcher/ensure-is-approval.py | 2 +- tests/twisted/dispatcher/ensure-rapidly.py | 2 +- tests/twisted/dispatcher/exploding-bundles.py | 2 +- tests/twisted/dispatcher/fdo-21034.py | 2 +- tests/twisted/dispatcher/handle-channels-fails.py | 2 +- tests/twisted/dispatcher/lose-text.py | 2 +- .../twisted/dispatcher/recover-from-disconnect.py | 5 +- tests/twisted/dispatcher/redispatch-channels.py | 2 +- .../twisted/dispatcher/request-disabled-account.py | 2 +- .../dispatcher/respawn-activatable-observers.py | 2 +- tests/twisted/dispatcher/respawn-observers.py | 2 +- tests/twisted/dispatcher/some-delay-approvers.py | 2 +- tests/twisted/dispatcher/undispatchable.py | 2 +- tests/twisted/dispatcher/vanishing-client.py | 2 +- tests/twisted/mctest.py | 172 +++++++++++++++++++-- 73 files changed, 249 insertions(+), 117 deletions(-) diff --git a/tests/twisted/account-manager/account-basics.py b/tests/twisted/account-manager/account-basics.py index cff3a3f..4e643cc 100644 --- a/tests/twisted/account-manager/account-basics.py +++ b/tests/twisted/account-manager/account-basics.py @@ -46,7 +46,7 @@ def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_path = account.__dbus_object_path__ diff --git a/tests/twisted/account-manager/auto-connect.py b/tests/twisted/account-manager/auto-connect.py index c8b9184..46b1336 100644 --- a/tests/twisted/account-manager/auto-connect.py +++ b/tests/twisted/account-manager/auto-connect.py @@ -27,16 +27,13 @@ import dbus.service from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \ call_async, assertEquals -from mctest import exec_test, SimulatedConnection, create_fakecm_account, MC +from mctest import (exec_test, SimulatedConnection, + SimulatedConnectionManager, MC) import constants as cs -cm_name_ref = dbus.service.BusName( - cs.tp_name_prefix + '.ConnectionManager.fakecm', bus=dbus.SessionBus()) - account_id = 'fakecm/fakeprotocol/jc_2edenton_40unatco_2eint' def preseed(q, bus, fake_accounts_service): - accounts_dir = os.environ['MC_ACCOUNT_DIR'] try: @@ -78,6 +75,8 @@ def preseed(q, bus, fake_accounts_service): account_connections_file.close() def test(q, bus, unused, **kwargs): + simulated_cm = SimulatedConnectionManager(q, bus) + fake_accounts_service = kwargs['fake_accounts_service'] preseed(q, bus, fake_accounts_service) diff --git a/tests/twisted/account-manager/avatar-refresh.py b/tests/twisted/account-manager/avatar-refresh.py index e1c7051..f76d7fb 100644 --- a/tests/twisted/account-manager/avatar-refresh.py +++ b/tests/twisted/account-manager/avatar-refresh.py @@ -28,12 +28,10 @@ import dbus.service from servicetest import (EventPattern, tp_name_prefix, tp_path_prefix, call_async, assertEquals, sync_dbus) -from mctest import exec_test, SimulatedConnection, create_fakecm_account, MC +from mctest import (exec_test, SimulatedConnection, + SimulatedConnectionManager, MC) import constants as cs -cm_name_ref = dbus.service.BusName( - cs.tp_name_prefix + '.ConnectionManager.fakecm', bus=dbus.SessionBus()) - class Account(object): def __init__(self, fake_accounts_service, accounts_dir, avatars_persist, server_delays, local_avatar, remote_avatar): @@ -357,6 +355,8 @@ def preseed(q, bus, fake_accounts_service): return accounts def test(q, bus, unused, **kwargs): + simulated_cm = SimulatedConnectionManager(q, bus) + fake_accounts_service = kwargs['fake_accounts_service'] accounts = preseed(q, bus, fake_accounts_service) diff --git a/tests/twisted/account-manager/avatar.py b/tests/twisted/account-manager/avatar.py index 9677e8a..8bae300 100644 --- a/tests/twisted/account-manager/avatar.py +++ b/tests/twisted/account-manager/avatar.py @@ -29,7 +29,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "me@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/account-manager/connectivity.py b/tests/twisted/account-manager/connectivity.py index 95fac29..1e378dc 100644 --- a/tests/twisted/account-manager/connectivity.py +++ b/tests/twisted/account-manager/connectivity.py @@ -46,7 +46,7 @@ def test(q, bus, mc): {"account": "yum yum network manager", "password": "boo boo connman (although your API *is* simpler)", }, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) # While we're not connected to the internet, RequestConnection should not # be called. diff --git a/tests/twisted/account-manager/crashy-cm.py b/tests/twisted/account-manager/crashy-cm.py index 531c41a..ca8f0ae 100644 --- a/tests/twisted/account-manager/crashy-cm.py +++ b/tests/twisted/account-manager/crashy-cm.py @@ -38,7 +38,7 @@ def test(q, bus, mc): {"account": "someguy@example.com", "password": "secrecy", }, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params, + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params, cm_bus=cm_bus) account.Properties.Set(cs.ACCOUNT, 'Enabled', True) @@ -69,7 +69,7 @@ def test(q, bus, mc): # CM crashes conn.release_name() - del cm_name_ref + simulated_cm.release_name() cm_bus.flush() cm_bus.close() diff --git a/tests/twisted/account-manager/create-auto-connect.py b/tests/twisted/account-manager/create-auto-connect.py index 54acc27..45acda0 100644 --- a/tests/twisted/account-manager/create-auto-connect.py +++ b/tests/twisted/account-manager/create-auto-connect.py @@ -28,7 +28,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "smcv@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/account-manager/create-twice.py b/tests/twisted/account-manager/create-twice.py index 2f0c0e0..3f1b8e2 100644 --- a/tests/twisted/account-manager/create-twice.py +++ b/tests/twisted/account-manager/create-twice.py @@ -22,7 +22,7 @@ import dbus.service from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \ call_async -from mctest import exec_test, create_fakecm_account, get_account_manager +from mctest import exec_test, SimulatedConnectionManager, get_account_manager import constants as cs def test(q, bus, mc): @@ -35,8 +35,7 @@ def test(q, bus, mc): params = dbus.Dictionary({"account": "create-twice", "password": "secrecy"}, signature='sv') - cm_name_ref = dbus.service.BusName(cs.tp_name_prefix + - '.ConnectionManager.fakecm', bus=bus) + simulated_cm = SimulatedConnectionManager(q, bus) account_manager = bus.get_object(cs.AM, cs.AM_PATH) am_iface = dbus.Interface(account_manager, cs.AM) diff --git a/tests/twisted/account-manager/create-with-properties.py b/tests/twisted/account-manager/create-with-properties.py index 128ac94..8d02e2d 100644 --- a/tests/twisted/account-manager/create-with-properties.py +++ b/tests/twisted/account-manager/create-with-properties.py @@ -22,7 +22,7 @@ import dbus.service from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \ call_async, assertEquals, assertContains -from mctest import exec_test, create_fakecm_account, AccountManager +from mctest import (exec_test, SimulatedConnectionManager, AccountManager) import constants as cs def test(q, bus, mc): @@ -53,8 +53,7 @@ def test(q, bus, mc): params = dbus.Dictionary({"account": "anarki@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref = dbus.service.BusName(cs.tp_name_prefix + - '.ConnectionManager.fakecm', bus=bus) + simulated_cm = SimulatedConnectionManager(q, bus) creation_properties = dbus.Dictionary({ cs.ACCOUNT + '.Enabled': True, diff --git a/tests/twisted/account-manager/device-idle.py b/tests/twisted/account-manager/device-idle.py index 434544a..dcc76ec 100644 --- a/tests/twisted/account-manager/device-idle.py +++ b/tests/twisted/account-manager/device-idle.py @@ -82,7 +82,7 @@ def _create_and_enable(q, bus, mc, account_name, power_saving_supported, extra_interfaces = [cs.CONN_IFACE_POWER_SAVING] params = dbus.Dictionary({"account": account_name, "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params, extra_interfaces=extra_interfaces, expect_after_connect=expect_after_connect) diff --git a/tests/twisted/account-manager/enable-auto-connect.py b/tests/twisted/account-manager/enable-auto-connect.py index c5f9899..d8ff3ae 100644 --- a/tests/twisted/account-manager/enable-auto-connect.py +++ b/tests/twisted/account-manager/enable-auto-connect.py @@ -28,7 +28,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "smcv@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/account-manager/enable.py b/tests/twisted/account-manager/enable.py index 14525ff..db659f3 100644 --- a/tests/twisted/account-manager/enable.py +++ b/tests/twisted/account-manager/enable.py @@ -28,7 +28,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "smcv@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/account-manager/irc.py b/tests/twisted/account-manager/irc.py index 47612bd..0d0de71 100644 --- a/tests/twisted/account-manager/irc.py +++ b/tests/twisted/account-manager/irc.py @@ -32,7 +32,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "brucewayne", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/account-manager/make-valid.py b/tests/twisted/account-manager/make-valid.py index 33582c5..6e7ea34 100644 --- a/tests/twisted/account-manager/make-valid.py +++ b/tests/twisted/account-manager/make-valid.py @@ -27,12 +27,10 @@ import dbus.service from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \ call_async, sync_dbus -from mctest import exec_test, SimulatedConnection, create_fakecm_account, MC +from mctest import (exec_test, SimulatedConnection, create_fakecm_account, MC, + SimulatedConnectionManager) import constants as cs -cm_name_ref = dbus.service.BusName( - cs.tp_name_prefix + '.ConnectionManager.fakecm', bus=dbus.SessionBus()) - account1_id = 'fakecm/fakeprotocol/jc_2edenton_40unatco_2eint' account2_id = 'fakecm/fakeprotocol/jc_2edenton_40example_2ecom' @@ -95,6 +93,7 @@ def preseed(q, bus, fake_accounts_service): account_connections_file.close() def test(q, bus, unused, **kwargs): + simulated_cm = SimulatedConnectionManager(q, bus) # make sure RequestConnection doesn't get called yet events = [EventPattern('dbus-method-call', method='RequestConnection')] diff --git a/tests/twisted/account-manager/nickname.py b/tests/twisted/account-manager/nickname.py index b128942..e10342d 100644 --- a/tests/twisted/account-manager/nickname.py +++ b/tests/twisted/account-manager/nickname.py @@ -28,7 +28,7 @@ import constants as cs def test(q, bus, mc, nickname): params = dbus.Dictionary({"account": "wjt@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/account-manager/param-types.py b/tests/twisted/account-manager/param-types.py index 8dafd7f..68eff80 100644 --- a/tests/twisted/account-manager/param-types.py +++ b/tests/twisted/account-manager/param-types.py @@ -22,13 +22,13 @@ import dbus.service from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \ call_async -from mctest import exec_test, create_fakecm_account, get_account_manager +from mctest import (exec_test, create_fakecm_account, get_account_manager, + SimulatedConnectionManager) import constants as cs def test(q, bus, mc): - cm_name_ref = dbus.service.BusName( - cs.tp_name_prefix + '.ConnectionManager.onewitheverything', - bus=bus) + simulated_cm = SimulatedConnectionManager(q, bus, + cm_name='onewitheverything', protocol_names=['serializable']) # Get the AccountManager interface account_manager = get_account_manager(bus) diff --git a/tests/twisted/account-manager/presence.py b/tests/twisted/account-manager/presence.py index 4034593..9f04f67 100755 --- a/tests/twisted/account-manager/presence.py +++ b/tests/twisted/account-manager/presence.py @@ -28,7 +28,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "jc.denton@example.com", "password": "ionstorm"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) presence = dbus.Struct((dbus.UInt32(cs.PRESENCE_BUSY), 'busy', 'Fighting conspiracies'), signature='uss') diff --git a/tests/twisted/account-manager/reconnect.py b/tests/twisted/account-manager/reconnect.py index 64a3459..39624a9 100644 --- a/tests/twisted/account-manager/reconnect.py +++ b/tests/twisted/account-manager/reconnect.py @@ -27,13 +27,10 @@ from mctest import exec_test, SimulatedConnection, create_fakecm_account,\ import constants as cs def test(q, bus, mc): - cm_name_ref = dbus.service.BusName( - tp_name_prefix + '.ConnectionManager.fakecm', bus=bus) - # Create an account params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) # Events that indicate that Reconnect might have done something looks_like_reconnection = [ diff --git a/tests/twisted/account-manager/recover-from-disconnect.py b/tests/twisted/account-manager/recover-from-disconnect.py index 186d13d..932b470 100644 --- a/tests/twisted/account-manager/recover-from-disconnect.py +++ b/tests/twisted/account-manager/recover-from-disconnect.py @@ -29,7 +29,7 @@ def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy", "register": True}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) call_async(q, account.Properties, 'Set', cs.ACCOUNT, 'Enabled', False) q.expect('dbus-return', method='Set') diff --git a/tests/twisted/account-manager/req-conn-fails.py b/tests/twisted/account-manager/req-conn-fails.py index 632504e..b9f05cb 100644 --- a/tests/twisted/account-manager/req-conn-fails.py +++ b/tests/twisted/account-manager/req-conn-fails.py @@ -31,7 +31,7 @@ def test(q, bus, mc): {"account": "someguy@example.com", "password": "secrecy", }, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account.Properties.Set(cs.ACCOUNT, 'Enabled', True) diff --git a/tests/twisted/account-manager/request-online.py b/tests/twisted/account-manager/request-online.py index 94a0b83..1818684 100644 --- a/tests/twisted/account-manager/request-online.py +++ b/tests/twisted/account-manager/request-online.py @@ -30,9 +30,6 @@ from mctest import ( import constants as cs def test(q, bus, mc): - cm_name_ref = dbus.service.BusName( - tp_name_prefix + '.ConnectionManager.fakecm', bus=bus) - http_fixed_properties = dbus.Dictionary({ cs.CHANNEL + '.TargetHandleType': 1L, cs.CHANNEL + '.ChannelType': cs.CHANNEL_TYPE_STREAM_TUBE, @@ -50,7 +47,7 @@ def test(q, bus, mc): # Create an account params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) # The account is initially valid but disabled, and hence offline props = account.GetAll(cs.ACCOUNT, dbus_interface=cs.PROPERTIES_IFACE) diff --git a/tests/twisted/account-manager/server-drops-us.py b/tests/twisted/account-manager/server-drops-us.py index 30ce62a..9a9d6ca 100644 --- a/tests/twisted/account-manager/server-drops-us.py +++ b/tests/twisted/account-manager/server-drops-us.py @@ -30,11 +30,8 @@ params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') def test(q, bus, mc): - cm_name_ref = dbus.service.BusName( - tp_name_prefix + '.ConnectionManager.fakecm', bus=bus) - # Create an account - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/account-manager/service.py b/tests/twisted/account-manager/service.py index f7df990..7bed951 100644 --- a/tests/twisted/account-manager/service.py +++ b/tests/twisted/account-manager/service.py @@ -27,7 +27,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "wjt@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) srv_name = 'fu-bar-42' account_iface = dbus.Interface(account, cs.ACCOUNT) diff --git a/tests/twisted/account-manager/update-parameters.py b/tests/twisted/account-manager/update-parameters.py index 7249532..4fc3d3a 100644 --- a/tests/twisted/account-manager/update-parameters.py +++ b/tests/twisted/account-manager/update-parameters.py @@ -30,16 +30,13 @@ from mctest import exec_test, SimulatedConnection, create_fakecm_account,\ import constants as cs def test(q, bus, mc, **kwargs): - cm_name_ref = dbus.service.BusName( - tp_name_prefix + '.ConnectionManager.fakecm', bus=bus) - # Create an account params = dbus.Dictionary( {"account": "someguy@example.com", "password": "secrecy", "nickname": "albinoblacksheep", }, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) # Enable the account account.Set(cs.ACCOUNT, 'Enabled', True, diff --git a/tests/twisted/account-requests/cancel.py b/tests/twisted/account-requests/cancel.py index f236e5b..9effcbe 100644 --- a/tests/twisted/account-requests/cancel.py +++ b/tests/twisted/account-requests/cancel.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/account-requests/create-text.py b/tests/twisted/account-requests/create-text.py index e71aca9..c6d5922 100644 --- a/tests/twisted/account-requests/create-text.py +++ b/tests/twisted/account-requests/create-text.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/account-requests/delete-account-during-request.py b/tests/twisted/account-requests/delete-account-during-request.py index 348c45a..0b448eb 100644 --- a/tests/twisted/account-requests/delete-account-during-request.py +++ b/tests/twisted/account-requests/delete-account-during-request.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/account-storage/default-keyring-storage.py b/tests/twisted/account-storage/default-keyring-storage.py index 2d3b2fc..a785718 100644 --- a/tests/twisted/account-storage/default-keyring-storage.py +++ b/tests/twisted/account-storage/default-keyring-storage.py @@ -74,7 +74,7 @@ def test(q, bus, mc): params = dbus.Dictionary({"account": "dontdivert@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_path = account.__dbus_object_path__ diff --git a/tests/twisted/account-storage/diverted-storage.py b/tests/twisted/account-storage/diverted-storage.py index 8692b09..2346b85 100644 --- a/tests/twisted/account-storage/diverted-storage.py +++ b/tests/twisted/account-storage/diverted-storage.py @@ -53,7 +53,7 @@ def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_path = account.__dbus_object_path__ diff --git a/tests/twisted/account/addressing.py b/tests/twisted/account/addressing.py index e303c93..222546b 100755 --- a/tests/twisted/account/addressing.py +++ b/tests/twisted/account/addressing.py @@ -31,7 +31,7 @@ def test(q, bus, mc): params = dbus.Dictionary ({"account": "jc.denton@example.com", "password": "ionstorm"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account (q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account (q, bus, mc, params) account_iface = dbus.Interface (account, cs.ACCOUNT) account_props = dbus.Interface (account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/capabilities/contact-caps.py b/tests/twisted/capabilities/contact-caps.py index 72fddcf..320a8c5 100644 --- a/tests/twisted/capabilities/contact-caps.py +++ b/tests/twisted/capabilities/contact-caps.py @@ -97,7 +97,7 @@ def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn, before = enable_fakecm_account(q, bus, mc, account, params, extra_interfaces=[cs.CONN_IFACE_CONTACT_CAPS], expect_before_connect=[ diff --git a/tests/twisted/crash-recovery/crash-recovery.py b/tests/twisted/crash-recovery/crash-recovery.py index 2bc4534..1656ab1 100644 --- a/tests/twisted/crash-recovery/crash-recovery.py +++ b/tests/twisted/crash-recovery/crash-recovery.py @@ -27,7 +27,7 @@ import dbus.service from servicetest import EventPattern, call_async from mctest import exec_test, SimulatedConnection, SimulatedClient, \ - create_fakecm_account, enable_fakecm_account, SimulatedChannel, \ + SimulatedChannel, \ expect_client_setup, MC import constants as cs diff --git a/tests/twisted/dispatcher/already-has-channel.py b/tests/twisted/dispatcher/already-has-channel.py index 9c033af..6b666e1 100644 --- a/tests/twisted/dispatcher/already-has-channel.py +++ b/tests/twisted/dispatcher/already-has-channel.py @@ -33,7 +33,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) text_fixed_properties = dbus.Dictionary({ cs.CHANNEL + '.TargetHandleType': cs.HT_CONTACT, diff --git a/tests/twisted/dispatcher/approver-fails.py b/tests/twisted/dispatcher/approver-fails.py index 67ce36a..b8705bb 100644 --- a/tests/twisted/dispatcher/approver-fails.py +++ b/tests/twisted/dispatcher/approver-fails.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/bypass-approval.py b/tests/twisted/dispatcher/bypass-approval.py index 0655a9a..eddb315 100644 --- a/tests/twisted/dispatcher/bypass-approval.py +++ b/tests/twisted/dispatcher/bypass-approval.py @@ -181,7 +181,7 @@ def expect_and_exercise_approval(q, bus, chan, channel_properties, def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) # Two clients want to observe, approve and handle channels. Additionally, diff --git a/tests/twisted/dispatcher/bypass-observers.py b/tests/twisted/dispatcher/bypass-observers.py index d8b0266..1aeb318 100644 --- a/tests/twisted/dispatcher/bypass-observers.py +++ b/tests/twisted/dispatcher/bypass-observers.py @@ -182,7 +182,7 @@ def expect_and_exercise_approval(q, bus, chan, channel_properties, def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) # Two clients want to observe, approve and handle channels. Additionally, diff --git a/tests/twisted/dispatcher/cancel.py b/tests/twisted/dispatcher/cancel.py index 5b8d90a..fe23f00 100644 --- a/tests/twisted/dispatcher/cancel.py +++ b/tests/twisted/dispatcher/cancel.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/capture-bundle.py b/tests/twisted/dispatcher/capture-bundle.py index 6b75d83..44e18e8 100644 --- a/tests/twisted/dispatcher/capture-bundle.py +++ b/tests/twisted/dispatcher/capture-bundle.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/cdo-claim.py b/tests/twisted/dispatcher/cdo-claim.py index ec98b93..89474f9 100644 --- a/tests/twisted/dispatcher/cdo-claim.py +++ b/tests/twisted/dispatcher/cdo-claim.py @@ -30,7 +30,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/connect-for-request.py b/tests/twisted/dispatcher/connect-for-request.py index 1163752..034cd05 100644 --- a/tests/twisted/dispatcher/connect-for-request.py +++ b/tests/twisted/dispatcher/connect-for-request.py @@ -29,7 +29,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "smcv@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/dispatcher/create-at-startup.py b/tests/twisted/dispatcher/create-at-startup.py index 7537faa..fb51572 100644 --- a/tests/twisted/dispatcher/create-at-startup.py +++ b/tests/twisted/dispatcher/create-at-startup.py @@ -28,7 +28,7 @@ import dbus.service from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \ call_async from mctest import exec_test, SimulatedConnection, SimulatedClient, \ - create_fakecm_account, enable_fakecm_account, SimulatedChannel, \ + SimulatedConnectionManager, SimulatedChannel, \ expect_client_setup, MC import constants as cs @@ -76,8 +76,7 @@ def test(q, bus, unused, **kwargs): observe=[text_fixed_properties], approve=[text_fixed_properties], handle=[text_fixed_properties], bypass_approval=False, implement_get_interfaces=False) - cm_name_ref = dbus.service.BusName( - cs.tp_name_prefix + '.ConnectionManager.fakecm', bus=bus) + simulated_cm = SimulatedConnectionManager(q, bus) # service-activate MC; it will try to introspect the running client. mc = MC(q, bus, wait_for_names=False) diff --git a/tests/twisted/dispatcher/create-delayed-by-mini-plugin.py b/tests/twisted/dispatcher/create-delayed-by-mini-plugin.py index 1c7c926..fcf021b 100644 --- a/tests/twisted/dispatcher/create-delayed-by-mini-plugin.py +++ b/tests/twisted/dispatcher/create-delayed-by-mini-plugin.py @@ -41,7 +41,7 @@ def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn, e = enable_fakecm_account(q, bus, mc, account, params, extra_interfaces=[cs.CONN_IFACE_SERVICE_POINT], expect_after_connect=[ diff --git a/tests/twisted/dispatcher/create-handler-fails.py b/tests/twisted/dispatcher/create-handler-fails.py index ccdae2f..1352363 100644 --- a/tests/twisted/dispatcher/create-handler-fails.py +++ b/tests/twisted/dispatcher/create-handler-fails.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/create-hints.py b/tests/twisted/dispatcher/create-hints.py index daf8cdc..3b8cf94 100644 --- a/tests/twisted/dispatcher/create-hints.py +++ b/tests/twisted/dispatcher/create-hints.py @@ -33,7 +33,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/create-no-preferred-handler.py b/tests/twisted/dispatcher/create-no-preferred-handler.py index 3e07841..11ac44b 100644 --- a/tests/twisted/dispatcher/create-no-preferred-handler.py +++ b/tests/twisted/dispatcher/create-no-preferred-handler.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/create-rejected-by-mini-plugin.py b/tests/twisted/dispatcher/create-rejected-by-mini-plugin.py index 2f51758..ecd5f6e 100644 --- a/tests/twisted/dispatcher/create-rejected-by-mini-plugin.py +++ b/tests/twisted/dispatcher/create-rejected-by-mini-plugin.py @@ -47,7 +47,7 @@ def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/create-text.py b/tests/twisted/dispatcher/create-text.py index a09ae98..a0897ba 100644 --- a/tests/twisted/dispatcher/create-text.py +++ b/tests/twisted/dispatcher/create-text.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/created-behind-our-back.py b/tests/twisted/dispatcher/created-behind-our-back.py index 55d1b4b..d87e69a 100644 --- a/tests/twisted/dispatcher/created-behind-our-back.py +++ b/tests/twisted/dispatcher/created-behind-our-back.py @@ -39,7 +39,7 @@ def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/delay-approvers.py b/tests/twisted/dispatcher/delay-approvers.py index a627159..2a7295f 100644 --- a/tests/twisted/dispatcher/delay-approvers.py +++ b/tests/twisted/dispatcher/delay-approvers.py @@ -29,7 +29,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/delay-then-call-handle-with.py b/tests/twisted/dispatcher/delay-then-call-handle-with.py index 2f79b10..28fdfb3 100644 --- a/tests/twisted/dispatcher/delay-then-call-handle-with.py +++ b/tests/twisted/dispatcher/delay-then-call-handle-with.py @@ -29,7 +29,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/delay-then-dont-call-approvers.py b/tests/twisted/dispatcher/delay-then-dont-call-approvers.py index 9004022..25ebd90 100644 --- a/tests/twisted/dispatcher/delay-then-dont-call-approvers.py +++ b/tests/twisted/dispatcher/delay-then-dont-call-approvers.py @@ -29,7 +29,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/dispatch-activatable.py b/tests/twisted/dispatcher/dispatch-activatable.py index cb7b9cb..6da442b 100644 --- a/tests/twisted/dispatcher/dispatch-activatable.py +++ b/tests/twisted/dispatcher/dispatch-activatable.py @@ -33,7 +33,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) abiword_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/dispatch-before-connected.py b/tests/twisted/dispatcher/dispatch-before-connected.py index 4d8d0db..1037ef4 100644 --- a/tests/twisted/dispatcher/dispatch-before-connected.py +++ b/tests/twisted/dispatcher/dispatch-before-connected.py @@ -32,7 +32,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someone@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py b/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py index 48da4c1..d2c0855 100644 --- a/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py +++ b/tests/twisted/dispatcher/dispatch-delayed-by-mini-plugin.py @@ -99,7 +99,7 @@ def signal_channel_expect_query(q, bus, account, conn, empathy, kopete): def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) policy_bus_name_ref = dbus.service.BusName('com.example.Policy', bus) diff --git a/tests/twisted/dispatcher/dispatch-obsolete.py b/tests/twisted/dispatcher/dispatch-obsolete.py index afe5df6..16d7651 100644 --- a/tests/twisted/dispatcher/dispatch-obsolete.py +++ b/tests/twisted/dispatcher/dispatch-obsolete.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params, has_requests=False) diff --git a/tests/twisted/dispatcher/dispatch-rejected-by-mini-plugin.py b/tests/twisted/dispatcher/dispatch-rejected-by-mini-plugin.py index 893ff14..37a8710 100644 --- a/tests/twisted/dispatcher/dispatch-rejected-by-mini-plugin.py +++ b/tests/twisted/dispatcher/dispatch-rejected-by-mini-plugin.py @@ -33,7 +33,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/dispatch-text.py b/tests/twisted/dispatcher/dispatch-text.py index b1f6ce6..689639c 100644 --- a/tests/twisted/dispatcher/dispatch-text.py +++ b/tests/twisted/dispatcher/dispatch-text.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/ensure-and-redispatch.py b/tests/twisted/dispatcher/ensure-and-redispatch.py index 4d526c2..f5a77a5 100644 --- a/tests/twisted/dispatcher/ensure-and-redispatch.py +++ b/tests/twisted/dispatcher/ensure-and-redispatch.py @@ -33,7 +33,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/ensure-is-approval.py b/tests/twisted/dispatcher/ensure-is-approval.py index a2fb085..63c6f8a 100644 --- a/tests/twisted/dispatcher/ensure-is-approval.py +++ b/tests/twisted/dispatcher/ensure-is-approval.py @@ -35,7 +35,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) # One client (Kopete) has less specific filters than the other (Empathy), diff --git a/tests/twisted/dispatcher/ensure-rapidly.py b/tests/twisted/dispatcher/ensure-rapidly.py index a338799..f90a1f6 100644 --- a/tests/twisted/dispatcher/ensure-rapidly.py +++ b/tests/twisted/dispatcher/ensure-rapidly.py @@ -33,7 +33,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/exploding-bundles.py b/tests/twisted/dispatcher/exploding-bundles.py index a8f06c3..27d1727 100644 --- a/tests/twisted/dispatcher/exploding-bundles.py +++ b/tests/twisted/dispatcher/exploding-bundles.py @@ -33,7 +33,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/fdo-21034.py b/tests/twisted/dispatcher/fdo-21034.py index 5a1ca3c..e0ed001 100644 --- a/tests/twisted/dispatcher/fdo-21034.py +++ b/tests/twisted/dispatcher/fdo-21034.py @@ -33,7 +33,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/handle-channels-fails.py b/tests/twisted/dispatcher/handle-channels-fails.py index 04b51ef..4b3ae22 100644 --- a/tests/twisted/dispatcher/handle-channels-fails.py +++ b/tests/twisted/dispatcher/handle-channels-fails.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/lose-text.py b/tests/twisted/dispatcher/lose-text.py index d652658..42083c2 100644 --- a/tests/twisted/dispatcher/lose-text.py +++ b/tests/twisted/dispatcher/lose-text.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/recover-from-disconnect.py b/tests/twisted/dispatcher/recover-from-disconnect.py index 4816771..9e0d3c4 100644 --- a/tests/twisted/dispatcher/recover-from-disconnect.py +++ b/tests/twisted/dispatcher/recover-from-disconnect.py @@ -48,13 +48,10 @@ def test(q, bus, mc): # wait for MC to download the properties expect_client_setup(q, [empathy, kopete]) - cm_name_ref = dbus.service.BusName( - tp_name_prefix + '.ConnectionManager.fakecm', bus=bus) - # Create an account params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/dispatcher/redispatch-channels.py b/tests/twisted/dispatcher/redispatch-channels.py index 6178a37..41800b1 100644 --- a/tests/twisted/dispatcher/redispatch-channels.py +++ b/tests/twisted/dispatcher/redispatch-channels.py @@ -185,7 +185,7 @@ def test_delegate_channel(q, bus, mc, account, conn, chan, empathy, empathy_bus, def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/request-disabled-account.py b/tests/twisted/dispatcher/request-disabled-account.py index adb3ca2..c3f1640 100644 --- a/tests/twisted/dispatcher/request-disabled-account.py +++ b/tests/twisted/dispatcher/request-disabled-account.py @@ -29,7 +29,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "smcv@example.com", "password": "secrecy"}, signature='sv') - (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) + (simulated_cm, account) = create_fakecm_account(q, bus, mc, params) account_iface = dbus.Interface(account, cs.ACCOUNT) account_props = dbus.Interface(account, cs.PROPERTIES_IFACE) diff --git a/tests/twisted/dispatcher/respawn-activatable-observers.py b/tests/twisted/dispatcher/respawn-activatable-observers.py index 8f83ffb..14727b4 100644 --- a/tests/twisted/dispatcher/respawn-activatable-observers.py +++ b/tests/twisted/dispatcher/respawn-activatable-observers.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/respawn-observers.py b/tests/twisted/dispatcher/respawn-observers.py index 81061ae..bf69a79 100644 --- a/tests/twisted/dispatcher/respawn-observers.py +++ b/tests/twisted/dispatcher/respawn-observers.py @@ -34,7 +34,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/some-delay-approvers.py b/tests/twisted/dispatcher/some-delay-approvers.py index e06b13a..16e0b7b 100644 --- a/tests/twisted/dispatcher/some-delay-approvers.py +++ b/tests/twisted/dispatcher/some-delay-approvers.py @@ -29,7 +29,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/undispatchable.py b/tests/twisted/dispatcher/undispatchable.py index de63fbc..8a18ec0 100644 --- a/tests/twisted/dispatcher/undispatchable.py +++ b/tests/twisted/dispatcher/undispatchable.py @@ -35,7 +35,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) text_fixed_properties = dbus.Dictionary({ diff --git a/tests/twisted/dispatcher/vanishing-client.py b/tests/twisted/dispatcher/vanishing-client.py index 92a4079..143ea4c 100644 --- a/tests/twisted/dispatcher/vanishing-client.py +++ b/tests/twisted/dispatcher/vanishing-client.py @@ -33,7 +33,7 @@ import constants as cs def test(q, bus, mc): params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') - cm_name_ref, account = create_fakecm_account(q, bus, mc, params) + simulated_cm, account = create_fakecm_account(q, bus, mc, params) conn = enable_fakecm_account(q, bus, mc, account, params) bus_name = '.'.join([tp_name_prefix, 'Client.CrashMe']) diff --git a/tests/twisted/mctest.py b/tests/twisted/mctest.py index 653cba1..debc6f4 100644 --- a/tests/twisted/mctest.py +++ b/tests/twisted/mctest.py @@ -1005,11 +1005,155 @@ class SimulatedClient(object): self.q.dbus_return(e.message, self.recover, signature='v', bus=self.bus) +class SimulatedConnectionManager(object): + def __init__(self, q, bus, cm_name='fakecm', + protocol_names=['fakeprotocol'], + has_account_storage=False): + self.q = q + self.bus = bus + self.cm_name = cm_name + self.bus_name = '.'.join([cs.CM, cm_name]) + self._bus_name_ref = dbus.service.BusName(self.bus_name, self.bus) + self.object_path = '/' + self.bus_name.replace('.', '/') + self.has_account_storage = has_account_storage + self.protocol_names = list(protocol_names) + + q.add_dbus_method_impl(self.GetAll_CM, + path=self.object_path, + interface=cs.PROPERTIES_IFACE, method='GetAll', + args=[cs.CM]) + + for protocol_name in protocol_names: + assert '-' not in protocol_name + q.add_dbus_method_impl(self.IdentifyAccount, + path=self.object_path + '/' + protocol_name, + interface=cs.PROTOCOL, method='IdentifyAccount') + q.add_dbus_method_impl(self.NormalizeContact, + path=self.object_path + '/' + protocol_name, + interface=cs.PROTOCOL, method='NormalizeContact') + + def release_name(self): + del self._bus_name_ref + + def reacquire_name(self): + self._bus_name_ref = dbus.service.BusName(self.bus_name, self.bus) + + def get_protocols(self): + ret = dbus.Dictionary(signature='sa{sv}') + + for p in self.protocol_names: + # stub: assume all the protocols look "reasonably normal" + ret[p] = { + cs.PROTOCOL + '.Interfaces': dbus.Array(signature='s'), + cs.PROTOCOL + '.ConnectionInterfaces': + dbus.Array(signature='s'), + cs.PROTOCOL + '.RequestableChannelClasses': + dbus.Array(signature='(a{sv}as)'), + cs.PROTOCOL + '.VCardField': 'x-' + self.cm_name, + cs.PROTOCOL + '.EnglishName': self.cm_name, + cs.PROTOCOL + '.Icon': 'im-' + self.cm_name, + cs.PROTOCOL + '.AuthenticationTypes': + dbus.Array(signature='s'), + cs.PROTOCOL + '.Parameters': dbus.Array([ + ('account', cs.PARAM_REQUIRED, 's', ''), + ('password', cs.PARAM_SECRET, 's', ''), + ], signature='(susv)'), + } + + if self.cm_name == 'fakecm' and p == 'fakeprotocol': + ret[p][cs.PROTOCOL + '.Parameters'] = dbus.Array([ + ('account', cs.PARAM_REQUIRED|cs.PARAM_REGISTER, + 's', ''), + ('password', + cs.PARAM_SECRET|cs.PARAM_REQUIRED|cs.PARAM_REGISTER, + 's', ''), + ('nickname', cs.PARAM_REGISTER, 's', ''), + ('register', cs.PARAM_HAS_DEFAULT, 'b', False), + ('com.example.Badgerable.Badgered', + cs.PARAM_HAS_DEFAULT|cs.PARAM_DBUS_PROPERTY, + 'b', False), + ('secret-mushroom', cs.PARAM_SECRET, 's', ''), + ('snakes', 0, 'u', dbus.UInt32(0)), + ('contrived-example', cs.PARAM_HAS_DEFAULT, 'u', + dbus.UInt32(5)), + ], signature='(susv)') + + if self.cm_name == 'onewitheverything' and p == 'serializable': + ret[p][cs.PROTOCOL + '.Parameters'] = dbus.Array([ + ('s', cs.PARAM_REQUIRED, 's', ''), + ('o', 0, 'o', dbus.ObjectPath('/')), + ('b', 0, 'b', False), + ('q', 0, 'q', dbus.UInt16(0)), + ('u', 0, 'u', dbus.UInt32(0)), + ('t', 0, 't', dbus.UInt64(0)), + ('n', 0, 'n', dbus.Int16(0)), + ('i', 0, 'i', dbus.Int32(0)), + ('x', 0, 'x', dbus.Int64(0)), + ('d', 0, 'd', 0.0), + ('as', 0, 'as', dbus.Array(signature=s)), + ('y', 0, 'y', dbus.Byte(0)), + ], signature='(susv)') + + if self.cm_name == 'onewitheverything' and p == 'defaults': + ret[p][cs.PROTOCOL + '.Parameters'] = dbus.Array([ + ('s', cs.PARAM_HAS_DEFAULT, 's', 'foo'), + ('o', cs.PARAM_HAS_DEFAULT, 'o', dbus.ObjectPath('/foo')), + ('b', cs.PARAM_HAS_DEFAULT, 'b', True), + ('q', cs.PARAM_HAS_DEFAULT, 'q', dbus.UInt16(1)), + ('u', cs.PARAM_HAS_DEFAULT, 'u', dbus.UInt32(1)), + ('t', cs.PARAM_HAS_DEFAULT, 't', dbus.UInt64(1)), + ('n', cs.PARAM_HAS_DEFAULT, 'n', dbus.Int16(-1)), + ('i', cs.PARAM_HAS_DEFAULT, 'i', dbus.Int32(-1)), + ('x', cs.PARAM_HAS_DEFAULT, 'x', dbus.Int64(-1)), + ('d', cs.PARAM_HAS_DEFAULT, 'd', 1.5), + ('as', cs.PARAM_HAS_DEFAULT, 'as', + dbus.Array(['foo', 'bar', 'baz'], signature=s)), + ('y', cs.PARAM_HAS_DEFAULT, 'y', dbus.Byte(1)), + ], signature='(susv)') + + if self.cm_name == 'onewitheverything' and p == 'flags': + ret[p][cs.PROTOCOL + '.Parameters'] = dbus.Array([ + ('account', cs.PARAM_REQUIRED|cs.PARAM_REGISTER, 's', ''), + ('name', cs.PARAM_REGISTER, 's', ''), + ('key', + cs.PARAM_REGISTER|cs.PARAM_REQUIRED|cs.PARAM_SECRET, + 's', ''), + ('com.example.Badgerable.Badgers', cs.PARAM_DBUS_PROPERTY, + 's', ''), + ], signature='(susv)') + + return ret + + def get_interfaces(self): + ret = dbus.Array([], signature='s') + + if self.has_account_storage: + ret.append(cs.CM_IFACE_ACCOUNT_STORAGE) + + return ret + + def GetAll_CM(self, e): + self.q.dbus_return(e.message, { + 'Protocols': self.get_protocols(), + 'Interfaces': self.get_interfaces(), + }, signature='a{sv}', bus=self.bus) + + def IdentifyAccount(self, e): + if 'account' in e.args[0]: + ret = e.args[0]['account'].lower() + else: + ret = 'account' + self.q.dbus_return(e.message, ret, signature='s') + + def NormalizeContact(self, e): + self.q.dbus_return(e.message, e.args[0].lower(), signature='s') + def take_fakecm_name(bus): return dbus.service.BusName(cs.CM + '.fakecm', bus=bus) def create_fakecm_account(q, bus, mc, params, properties={}, - cm_bus=None): + cm_bus=None, simulated_cm=None, + cm_name='fakecm', protocol_name='fakeprotocol'): """Create a fake connection manager and an account that uses it. Optional keyword arguments: @@ -1024,12 +1168,14 @@ def create_fakecm_account(q, bus, mc, params, properties={}, if cm_bus is None: cm_bus = bus - cm_name_ref = take_fakecm_name(cm_bus) + if simulated_cm is None: + simulated_cm = SimulatedConnectionManager(q, bus, + cm_name=cm_name, protocol_names=[protocol_name]) account_manager = AccountManager(bus) servicetest.call_async(q, account_manager, 'CreateAccount', - 'fakecm', 'fakeprotocol', 'fakeaccount', params, properties) + cm_name, protocol_name, 'fakeaccount', params, properties) validity_changed_pattern = servicetest.EventPattern('dbus-signal', path=cs.AM_PATH, signal='AccountValidityChanged', interface=cs.AM) @@ -1056,7 +1202,7 @@ def create_fakecm_account(q, bus, mc, params, properties={}, interface, prop = key.rsplit('.', 1) servicetest.assertEquals(value, account.Properties.Get(interface, prop)) - return (cm_name_ref, account) + return (simulated_cm, account) def get_fakecm_account(bus, mc, account_path): account = Account(bus, account_path) @@ -1096,19 +1242,25 @@ def expect_fakecm_connection(q, bus, mc, account, expected_params, extra_interfaces=[], expect_before_connect=(), expect_after_connect=(), has_hidden=False, - self_ident='myself'): + self_ident='myself', + cm_name='fakecm', + protocol_name='fakeprotocol'): # make (safely) mutable copies expect_before_connect = list(expect_before_connect) expect_after_connect = list(expect_after_connect) + # for simplicity we assume the sort of name that is invariant between + # Telepathy 0 and Telepathy 1 + assert '-' not in protocol_name + e = q.expect('dbus-method-call', method='RequestConnection', - args=['fakeprotocol', expected_params], - destination=cs.tp_name_prefix + '.ConnectionManager.fakecm', - path=cs.tp_path_prefix + '/ConnectionManager/fakecm', - interface=cs.tp_name_prefix + '.ConnectionManager', + args=[protocol_name, expected_params], + destination=cs.CM + '.' + cm_name, + path='/' + cs.CM.replace('.', '/') + '/' + cm_name, + interface=cs.CM, handled=False) - conn = SimulatedConnection(q, bus, 'fakecm', 'fakeprotocol', + conn = SimulatedConnection(q, bus, cm_name, protocol_name, account.object_path.split('/')[-1], self_ident, has_requests=has_requests, has_presence=has_presence, has_aliasing=has_aliasing, has_avatars=has_avatars, -- 1.8.4.rc3