diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2011-09-13 11:54:34 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2011-09-13 12:33:36 +0100 |
commit | 57175d04e0b70a112de89e9d85e0e753915780e1 (patch) | |
tree | 31c040c190cf274f2441b8e5e6cbe788eda5eb2e /tests | |
parent | cb19851532bb95ef18e162fc055dbed8c4d579d9 (diff) |
mctest: allow running FakeCM on a separate bus connection
This was possible before, but not exactly straightforward: you had to
clone the guts of create_fakecm_account(). By adding an optional
parameter to create_fakecm_account(), and a method to
SimulatedConnection to drop its bus name, it becomes pretty easy to run
the fake CM on a separate bus, and hence simulate it crashing.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/twisted/mctest.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/twisted/mctest.py b/tests/twisted/mctest.py index bd0db02c..417cd4d3 100644 --- a/tests/twisted/mctest.py +++ b/tests/twisted/mctest.py @@ -323,6 +323,9 @@ class SimulatedConnection(object): self.presence = dbus.Struct((cs.PRESENCE_TYPE_OFFLINE, 'offline', ''), signature='uss') + def release_name(self): + del self._bus_name_ref + def GetAll_Connection(self, e): self.q.dbus_return(e.message, { 'Interfaces': dbus.Array(self.interfaces, signature='s'), @@ -828,17 +831,24 @@ class SimulatedClient(object): def take_fakecm_name(bus): return dbus.service.BusName(cs.CM + '.fakecm', bus=bus) -def create_fakecm_account(q, bus, mc, params, properties={}): +def create_fakecm_account(q, bus, mc, params, properties={}, + cm_bus=None): """Create a fake connection manager and an account that uses it. Optional keyword arguments: properties -- a dictionary from qualified property names to values to pass to CreateAccount. If provided, this function will check that the newly-created account has these properties. + cm_bus -- if not None, a BusConnection via which to claim the CM's + name. If None, 'bus' will be used. Returns: (a BusName for the fake CM, an Account proxy)""" - cm_name_ref = take_fakecm_name(bus) + if cm_bus is None: + cm_bus = bus + + cm_name_ref = take_fakecm_name(cm_bus) + account_manager = AccountManager(bus) servicetest.call_async(q, account_manager, 'CreateAccount', |