telepathy-mission-control: account-basics test: assert that the mock accounts service is used correctly
Simon McVittie
smcv at kemper.freedesktop.org
Wed Feb 13 06:23:50 PST 2013
Module: telepathy-mission-control
Branch: master
Commit: 2ecab4c8c5109722bbf7c0f2df8d7d2c6aa64c6c
URL: http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=2ecab4c8c5109722bbf7c0f2df8d7d2c6aa64c6c
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Mon Sep 10 14:57:21 2012 +0100
account-basics test: assert that the mock accounts service is used correctly
---
tests/twisted/account-manager/account-basics.py | 110 ++++++++++++++++++++++-
1 files changed, 108 insertions(+), 2 deletions(-)
diff --git a/tests/twisted/account-manager/account-basics.py b/tests/twisted/account-manager/account-basics.py
index ec21a51..18b35cb 100644
--- a/tests/twisted/account-manager/account-basics.py
+++ b/tests/twisted/account-manager/account-basics.py
@@ -99,6 +99,22 @@ def test(q, bus, mc):
signal='AccountPropertyChanged',
interface=cs.ACCOUNT,
args=[{'DisplayName': 'Work account'}]),
+ EventPattern('dbus-signal',
+ interface=cs.TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
+ signal='DeferringSetAttribute',
+ args=[account_path, 'DisplayName', 'Work account']),
+ EventPattern('dbus-signal',
+ interface=cs.TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
+ signal='CommittingOne',
+ args=[account_path]),
+ EventPattern('dbus-method-call',
+ interface=cs.TEST_DBUS_ACCOUNT_SERVICE_IFACE,
+ method='UpdateAttributes',
+ args=[account_path[len(cs.ACCOUNT_PATH_PREFIX):],
+ {'DisplayName': 'Work account'},
+ {'DisplayName': 0}, # flags
+ []],
+ ),
EventPattern('dbus-return', method='Set'),
)
assert account_props.Get(cs.ACCOUNT, 'DisplayName') == 'Work account'
@@ -110,6 +126,22 @@ def test(q, bus, mc):
signal='AccountPropertyChanged',
interface=cs.ACCOUNT,
args=[{'Icon': 'im-jabber'}]),
+ EventPattern('dbus-signal',
+ interface=cs.TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
+ signal='DeferringSetAttribute',
+ args=[account_path, 'Icon', 'im-jabber']),
+ EventPattern('dbus-signal',
+ interface=cs.TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
+ signal='CommittingOne',
+ args=[account_path]),
+ EventPattern('dbus-method-call',
+ interface=cs.TEST_DBUS_ACCOUNT_SERVICE_IFACE,
+ method='UpdateAttributes',
+ args=[account_path[len(cs.ACCOUNT_PATH_PREFIX):],
+ {'Icon': 'im-jabber'},
+ {'Icon': 0}, # flags
+ []],
+ ),
EventPattern('dbus-return', method='Set'),
)
assert account_props.Get(cs.ACCOUNT, 'Icon') == 'im-jabber'
@@ -123,6 +155,22 @@ def test(q, bus, mc):
interface=cs.ACCOUNT,
args=[{'Nickname': 'Joe Bloggs'}]),
EventPattern('dbus-return', method='Set'),
+ EventPattern('dbus-signal',
+ interface=cs.TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
+ signal='DeferringSetAttribute',
+ args=[account_path, 'Nickname', 'Joe Bloggs']),
+ EventPattern('dbus-signal',
+ interface=cs.TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
+ signal='CommittingOne',
+ args=[account_path]),
+ EventPattern('dbus-method-call',
+ interface=cs.TEST_DBUS_ACCOUNT_SERVICE_IFACE,
+ method='UpdateAttributes',
+ args=[account_path[len(cs.ACCOUNT_PATH_PREFIX):],
+ {'Nickname': 'Joe Bloggs'},
+ {'Nickname': 0}, # flags
+ []],
+ ),
)
assert account_props.Get(cs.ACCOUNT, 'Nickname') == 'Joe Bloggs'
@@ -132,6 +180,22 @@ def test(q, bus, mc):
# there's no change notification for the Condition
q.expect_many(
EventPattern('dbus-return', method='Set'),
+ EventPattern('dbus-signal',
+ interface=cs.TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
+ signal='DeferringSetAttribute',
+ args=[account_path, 'condition-:foo', 'bar']),
+ EventPattern('dbus-signal',
+ interface=cs.TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
+ signal='CommittingOne',
+ args=[account_path]),
+ EventPattern('dbus-method-call',
+ interface=cs.TEST_DBUS_ACCOUNT_SERVICE_IFACE,
+ method='UpdateAttributes',
+ args=[account_path[len(cs.ACCOUNT_PATH_PREFIX):],
+ {'condition-:foo': 'bar'},
+ {'condition-:foo': 0}, # flags
+ []],
+ ),
)
assert account_props.Get(cs.ACCOUNT_IFACE_NOKIA_CONDITIONS,
'Condition') == {':foo': 'bar'}
@@ -148,6 +212,23 @@ def test(q, bus, mc):
interface=cs.ACCOUNT,
args=[{'Supersedes': [cs.ACCOUNT_PATH_PREFIX + 'x/y/z']}]),
EventPattern('dbus-return', method='Set'),
+ EventPattern('dbus-signal',
+ interface=cs.TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
+ signal='DeferringSetAttribute',
+ args=[account_path, 'Supersedes',
+ [cs.ACCOUNT_PATH_PREFIX + 'x/y/z']]),
+ EventPattern('dbus-signal',
+ interface=cs.TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
+ signal='CommittingOne',
+ args=[account_path]),
+ EventPattern('dbus-method-call',
+ interface=cs.TEST_DBUS_ACCOUNT_SERVICE_IFACE,
+ method='UpdateAttributes',
+ args=[account_path[len(cs.ACCOUNT_PATH_PREFIX):],
+ {'Supersedes': [cs.ACCOUNT_PATH_PREFIX + 'x/y/z']},
+ {'Supersedes': 0}, # flags
+ []],
+ ),
)
assertEquals(dbus.Array([cs.ACCOUNT_PATH_PREFIX + 'x/y/z'],
signature='o'),
@@ -157,6 +238,16 @@ def test(q, bus, mc):
# but is a no-op, although in future it should change to raising an
# exception
+ forbidden = [
+ EventPattern('dbus-signal',
+ interface=cs.TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
+ signal='DeferringSetAttribute'),
+ EventPattern('dbus-method-call',
+ interface=cs.TEST_DBUS_ACCOUNT_SERVICE_IFACE,
+ method='UpdateAttributes'),
+ ]
+ q.forbid_events(forbidden)
+
# this variable's D-Bus type must differ from the types of all known
# properties
badly_typed = dbus.Struct(('wrongly typed',), signature='s')
@@ -199,9 +290,12 @@ def test(q, bus, mc):
properties = account_props.GetAll(cs.ACCOUNT_IFACE_AVATAR)
assert properties['Avatar'] == ([], '')
+ q.unforbid_events(forbidden)
+
# Delete the account
- assert account_iface.Remove() is None
- account_event, account_manager_event = q.expect_many(
+ call_async(q, account_iface, 'Remove')
+ q.expect_many(
+ EventPattern('dbus-return', method='Remove'),
EventPattern('dbus-signal',
path=account_path,
signal='Removed',
@@ -214,6 +308,18 @@ def test(q, bus, mc):
interface=cs.AM,
args=[account_path]
),
+ EventPattern('dbus-signal',
+ interface=cs.TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
+ signal='DeferringDelete',
+ args=[account_path]),
+ EventPattern('dbus-signal',
+ interface=cs.TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
+ signal='CommittingOne',
+ args=[account_path]),
+ EventPattern('dbus-method-call',
+ interface=cs.TEST_DBUS_ACCOUNT_SERVICE_IFACE,
+ method='DeleteAccount',
+ args=[account_path[len(cs.ACCOUNT_PATH_PREFIX):]]),
)
# Check the account is correctly deleted
More information about the telepathy-commits
mailing list