From 992487eb70c8c7f700542fe5aac4d9292763339c Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Fri, 22 Apr 2011 15:06:56 +0300 Subject: [PATCH] Test to cover MUC JOIN initiated by the server Proxies and bouncers usually send a JOIN message to the client for each channel the user is a member of. Fixes: https://bugs.freedesktop.org/28918 --- tests/twisted/Makefile.am | 1 + tests/twisted/channels/join-muc-channel-bouncer.py | 49 ++++++++++++++++++++ 2 files changed, 50 insertions(+), 0 deletions(-) create mode 100644 tests/twisted/channels/join-muc-channel-bouncer.py diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index 6b61303..020e996 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -8,6 +8,7 @@ TWISTED_TESTS = \ connect/server-quit-noclose.py \ connect/invalid-nick.py \ channels/join-muc-channel.py \ + channels/join-muc-channel-bouncer.py \ channels/requests-create.py \ channels/requests-muc.py \ channels/muc-channel-topic.py \ diff --git a/tests/twisted/channels/join-muc-channel-bouncer.py b/tests/twisted/channels/join-muc-channel-bouncer.py new file mode 100644 index 0000000..37e4f65 --- /dev/null +++ b/tests/twisted/channels/join-muc-channel-bouncer.py @@ -0,0 +1,49 @@ + +""" +Test connecting to a IRC channel +""" + +from idletest import exec_test +from servicetest import EventPattern, call_async +from constants import * +import dbus + +def test(q, bus, conn, stream): + conn.Connect() + q.expect_many( + EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]), + EventPattern('irc-connected')) + q.expect('dbus-signal', signal='SelfHandleChanged', + args=[1L]) + q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]) + + room = "#idletest" + room_handles = conn.RequestHandles(HT_ROOM, [room]) + stream.sendJoin(room) + + pattern = EventPattern('dbus-signal', signal='NewChannels') + event = q.expect_many(pattern)[0] + q.forbid_events([pattern]) + channel_details = event.args[0] + assert len(channel_details) == 1 + path, props = channel_details[0] + assert props[TARGET_HANDLE_TYPE] == HT_ROOM + assert props[TARGET_HANDLE] == room_handles[0] + assert props[CHANNEL_TYPE] == CHANNEL_TYPE_TEXT + + pattern = EventPattern('dbus-signal', signal='NewChannel') + event = q.expect_many(pattern)[0] + q.forbid_events([pattern]) + assert event.args[1] == CHANNEL_TYPE_TEXT + assert event.args[2] == HT_ROOM + assert event.args[3] == room_handles[0] + + q.expect('dbus-signal', signal='MembersChanged') + call_async(q, conn, 'Disconnect') + q.expect_many( + EventPattern('dbus-return', method='Disconnect'), + EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1])) + return True + +if __name__ == '__main__': + exec_test(test) -- 1.7.4.2