diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2012-11-14 17:03:08 +0000 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2012-11-14 17:10:55 +0000 |
commit | 4fb86fc1be9bdea989fed9a21c5796a1eccba504 (patch) | |
tree | e16e89e2b838e996b296ac4b6c00d102843ef9ed | |
parent | 39ee2f08cf4e2d46aae86307f6dfa023fe347248 (diff) |
muc: check that messages are marked as rescued
-rw-r--r-- | tests/twisted/channels/muc-destroy.py | 37 | ||||
-rw-r--r-- | tests/twisted/channels/requests-muc.py | 16 |
2 files changed, 41 insertions, 12 deletions
diff --git a/tests/twisted/channels/muc-destroy.py b/tests/twisted/channels/muc-destroy.py index 3513098..b4c742b 100644 --- a/tests/twisted/channels/muc-destroy.py +++ b/tests/twisted/channels/muc-destroy.py @@ -2,31 +2,50 @@ Tests Destroy()ing a MUC. """ -from servicetest import call_async, wrap_channel, EventPattern +from servicetest import call_async, wrap_channel, EventPattern, assertLength from idletest import exec_test import constants as cs -def test(q, bus, conn, stream): - conn.Connect() - q.expect('dbus-signal', signal='StatusChanged', - args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]) +CHANNEL = "#everythingyoutouch" +def join(q, bus, conn): call_async(q, conn.Requests, "CreateChannel", { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, - cs.ROOM_NAME: "#everythingyoutouch", + cs.ROOM_NAME: CHANNEL, }) q.expect('stream-JOIN') event = q.expect('dbus-return', method='CreateChannel') path, props = event.value - chan = wrap_channel(bus.get_object(conn.bus_name, path), 'Text', - ['Destroyable']) + return wrap_channel(bus.get_object(conn.bus_name, path), 'Text', + ['Destroyable', 'Messages']) + +def test(q, bus, conn, stream): + conn.Connect() + q.expect('dbus-signal', signal='StatusChanged', + args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]) + + chan = join(q, bus, conn) + + stream.sendMessage('PRIVMSG', CHANNEL, ":who's underlined you?", prefix='marnie') + q.expect('dbus-signal', signal='MessageReceived') + # Without acking the message, destroy the channel. call_async(q, chan.Destroyable, "Destroy") q.expect_many( EventPattern('stream-PART'), - EventPattern('dbus-signal', signal='Closed', path=path), + EventPattern('dbus-signal', signal='Closed', path=chan.object_path), + EventPattern('dbus-signal', signal='ChannelClosed', args=[chan.object_path]), EventPattern('dbus-return', method='Destroy'), ) + # Now Create it again. If we haven't actually left the channel, this will + # fail. + chan = join(q, bus, conn) + + # The message should be gone. + messages = chan.Properties.Get(cs.CHANNEL_IFACE_MESSAGES, 'PendingMessages') + assertLength(0, messages) + + if __name__ == '__main__': exec_test(test) diff --git a/tests/twisted/channels/requests-muc.py b/tests/twisted/channels/requests-muc.py index 27de685..b54091c 100644 --- a/tests/twisted/channels/requests-muc.py +++ b/tests/twisted/channels/requests-muc.py @@ -5,8 +5,8 @@ Test connecting to a IRC channel via the Requests interface import functools from idletest import exec_test, BaseIRCServer, sync_stream from servicetest import ( - EventPattern, call_async, sync_dbus, make_channel_proxy, assertEquals, - assertSameSets, assertContains, + EventPattern, call_async, sync_dbus, wrap_channel, assertEquals, + assertSameSets, assertContains, assertLength, ) import constants as cs import dbus @@ -123,7 +123,12 @@ def test(q, bus, conn, stream, use_room=False): assert len(chans) == 1 assert chans[0] == (path, props) - chan = make_channel_proxy(conn, path, 'Channel') + chan = wrap_channel(bus.get_object(conn.bus_name, path), 'Text', + ['Destroyable', 'Messages']) + + # Put an unacknowledged message into the channel + stream.sendMessage('PRIVMSG', '#idletest', ':oi oi', prefix='lol') + q.expect('dbus-signal', signal='MessageReceived', path=path) # Make sure Close()ing the channel makes it respawn. This avoids the old # bug where empathy-chat crashing booted you out of all your channels. @@ -140,6 +145,11 @@ def test(q, bus, conn, stream, use_room=False): assertEquals(0, props[cs.INITIATOR_HANDLE]) assert not props[cs.REQUESTED] + # The unacknowledged message should still be there and be marked as rescued. + messages = chan.Properties.Get(cs.CHANNEL_IFACE_MESSAGES, 'PendingMessages') + assertLength(1, messages) + assert messages[0][0]['rescued'], messages[0] + # Check that ensuring a respawned channel does what you'd expect. ec_yours, ec_path, ec_props = conn.EnsureChannel(request, dbus_interface=cs.CONN_IFACE_REQUESTS) |