diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-01-11 13:46:05 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-01-11 14:42:56 +0000 |
commit | 85de913c2b4c58e8b11548adff72da2c85f9dc5e (patch) | |
tree | 6a5a0bb7b7664b7249dfd050d151a90bd7a87c5b /tests | |
parent | 4f7d751ccaa4154bb0b580f71cd6f1b6063c2490 (diff) | |
download | telepathy-gabble-85de913c2b4c58e8b11548adff72da2c85f9dc5e.tar.gz |
Extend presence/decloak.py to test altering DecloakAutomatically at runtime
Diffstat (limited to 'tests')
-rw-r--r-- | tests/twisted/presence/decloak.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/twisted/presence/decloak.py b/tests/twisted/presence/decloak.py index e1c715e1e..fed5078dc 100644 --- a/tests/twisted/presence/decloak.py +++ b/tests/twisted/presence/decloak.py @@ -1,7 +1,7 @@ from twisted.words.xish import domish from gabbletest import exec_test, make_presence -from servicetest import EventPattern +from servicetest import EventPattern, assertEquals import ns import constants as cs @@ -16,6 +16,20 @@ def test(q, bus, conn, stream, should_decloak=False): event.stanza['type'] = 'result' stream.send(event.stanza) + # First test is to use the CM param's value + worker(q, bus, conn, stream, should_decloak) + + # We can change it at runtime, so flip it to the other value and retry + should_decloak = not should_decloak + conn.Set(cs.CONN_IFACE_GABBLE_DECLOAK, 'DecloakAutomatically', + should_decloak, dbus_interface=cs.PROPERTIES_IFACE) + worker(q, bus, conn, stream, should_decloak) + +def worker(q, bus, conn, stream, should_decloak): + decloak_automatically = conn.Get(cs.CONN_IFACE_GABBLE_DECLOAK, + 'DecloakAutomatically', dbus_interface=cs.PROPERTIES_IFACE) + assertEquals(should_decloak, decloak_automatically) + amy_handle = conn.RequestHandles(1, ['amy@foo.com'])[0] # Amy directs presence to us @@ -29,14 +43,15 @@ def test(q, bus, conn, stream, should_decloak=False): EventPattern('dbus-signal', signal='PresencesChanged', args=[{amy_handle: (cs.PRESENCE_AVAILABLE, 'available', '')}]), ] + forbidden = [] if should_decloak: events.append(EventPattern('stream-presence', to='amy@foo.com/panopticon')) else: forbidden = [EventPattern('stream-presence')] - q.forbid_events(forbidden) + q.forbid_events(forbidden) q.expect_many(*events) presence = make_presence('amy@foo.com/panopticon', type='unavailable') @@ -44,6 +59,8 @@ def test(q, bus, conn, stream, should_decloak=False): q.expect('dbus-signal', signal='PresencesChanged', args=[{amy_handle: (cs.PRESENCE_OFFLINE, 'offline', '')}]) + q.unforbid_events(forbidden) + if __name__ == '__main__': exec_test(test) exec_test(lambda q, b, c, s: test(q, b, c, s, should_decloak=True), |