[telepathy-mission-control/master] account-manager/reconnect.py: assert that Reconnect is a no-op when it should be
Simon McVittie
simon.mcvittie at collabora.co.uk
Tue May 5 10:56:01 PDT 2009
---
test/twisted/account-manager/reconnect.py | 75 +++++++++++++++++++++++++----
1 files changed, 65 insertions(+), 10 deletions(-)
diff --git a/test/twisted/account-manager/reconnect.py b/test/twisted/account-manager/reconnect.py
index 4e79c88..c9d8195 100644
--- a/test/twisted/account-manager/reconnect.py
+++ b/test/twisted/account-manager/reconnect.py
@@ -1,7 +1,8 @@
import dbus
import dbus.service
-from servicetest import EventPattern, tp_name_prefix, tp_path_prefix
+from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
+ call_async, sync_dbus
from mctest import exec_test, SimulatedConnection, create_fakecm_account,\
SimulatedChannel
import constants as cs
@@ -15,17 +16,71 @@ def test(q, bus, mc):
"password": "secrecy"}, signature='sv')
(cm_name_ref, account) = create_fakecm_account(q, bus, mc, params)
+ # Events that indicate that Reconnect might have done something
+ looks_like_reconnection = [
+ EventPattern('dbus-method-call', method='RequestConnection'),
+ EventPattern('dbus-method-call', method='Disconnect'),
+ ]
+
+ q.forbid_events(looks_like_reconnection)
+
+ # While we want to be online but the account is disabled, Reconnect is a
+ # no-op. Set Enabled to False explicitly, so we're less reliant on initial
+ # state.
+
+ call_async(q, account, 'Set', cs.ACCOUNT, 'Enabled', False,
+ dbus_interface=cs.PROPERTIES_IFACE)
+ q.expect('dbus-return', method='Set')
+
+ requested_presence = dbus.Struct((dbus.UInt32(cs.PRESENCE_TYPE_AVAILABLE),
+ dbus.String(u'available'), dbus.String(u'')))
+ call_async(q, account, 'Set', cs.ACCOUNT,
+ 'RequestedPresence', requested_presence,
+ dbus_interface=cs.PROPERTIES_IFACE)
+ q.expect('dbus-return', method='Set')
+
+ call_async(q, account, 'Reconnect', dbus_interface=cs.ACCOUNT)
+ q.expect('dbus-return', method='Reconnect')
+
+ sync_dbus(bus, q, account)
+
+ # While we want to be offline but the account is enabled, Reconnect is
+ # still a no-op.
+ requested_presence = dbus.Struct((dbus.UInt32(cs.PRESENCE_TYPE_OFFLINE),
+ dbus.String(u'offline'), dbus.String(u'')))
+ call_async(q, account, 'Set', cs.ACCOUNT,
+ 'RequestedPresence', requested_presence,
+ dbus_interface=cs.PROPERTIES_IFACE)
+ q.expect_many(
+ EventPattern('dbus-return', method='Set'),
+ EventPattern('dbus-signal',
+ path=account.object_path,
+ signal='AccountPropertyChanged',
+ interface=cs.ACCOUNT),
+ )
+
# Enable the account
- account.Set(cs.ACCOUNT, 'Enabled', True,
+ call_async(q, account, 'Set', cs.ACCOUNT, 'Enabled', True,
dbus_interface=cs.PROPERTIES_IFACE)
- q.expect('dbus-signal',
- path=account.object_path,
- signal='AccountPropertyChanged',
- interface=cs.ACCOUNT)
-
- # Go online
- requested_presence = dbus.Struct((dbus.UInt32(2L), dbus.String(u'brb'),
- dbus.String(u'Be back soon!')))
+ q.expect_many(
+ EventPattern('dbus-return', method='Set'),
+ EventPattern('dbus-signal',
+ path=account.object_path,
+ signal='AccountPropertyChanged',
+ interface=cs.ACCOUNT),
+ )
+
+ call_async(q, account, 'Reconnect', dbus_interface=cs.ACCOUNT)
+ q.expect('dbus-return', method='Reconnect')
+
+ sync_dbus(bus, q, account)
+
+ # Actually go online now
+
+ q.unforbid_events(looks_like_reconnection)
+
+ requested_presence = dbus.Struct((dbus.UInt32(cs.PRESENCE_TYPE_AVAILABLE),
+ dbus.String(u'brb'), dbus.String(u'Be back soon!')))
account.Set(cs.ACCOUNT,
'RequestedPresence', requested_presence,
dbus_interface=cs.PROPERTIES_IFACE)
--
1.5.6.5
More information about the telepathy-commits
mailing list