telepathy-idle: Fix a bug and add a test for requesting multiple roomlist channels
Will Thompson
wjt at kemper.freedesktop.org
Mon Oct 29 05:39:12 PDT 2012
Module: telepathy-idle
Branch: master
Commit: dc777537db0f727951d51a09599c108f34b34dcd
URL: http://cgit.freedesktop.org/telepathy/telepathy-idle/commit/?id=dc777537db0f727951d51a09599c108f34b34dcd
Author: Jonathon Jongsma <jonathon.jongsma at collabora.co.uk>
Date: Thu Jan 29 16:34:23 2009 -0600
Fix a bug and add a test for requesting multiple roomlist channels
I hadn't really excercised the code for returning an existing roomlist channel
if we had already created one. So I added a test for it and in the process
discovered a bug, which is also fixed by this patch.
(The compiler found this bug when it was introduced while I was rebasing
Jonathon's branch, so I fixed it there and then. -Will)
---
tests/twisted/Makefile.am | 1 +
tests/twisted/channels/room-list-multiple.py | 61 ++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index e6b0005..b867240 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -16,6 +16,7 @@ TWISTED_TESTS = \
channels/requests-muc.py \
channels/muc-channel-topic.py \
channels/room-list-channel.py \
+ channels/room-list-multiple.py \
messages/accept-invalid-nicks.py \
messages/contactinfo-request.py \
messages/messages-iface.py \
diff --git a/tests/twisted/channels/room-list-multiple.py b/tests/twisted/channels/room-list-multiple.py
new file mode 100644
index 0000000..e168965
--- /dev/null
+++ b/tests/twisted/channels/room-list-multiple.py
@@ -0,0 +1,61 @@
+
+"""
+Test getting multiple room-list channels. telepathy-idle internally only
+creates a single roomlist channel (since there's not really any reason to have
+more than one) and passes that channel out whenever somebody asks for it.
+
+This test just excercises the case where we've already created the channel and
+we just need to hand it out to the next requestor
+"""
+
+from idletest import exec_test, BaseIRCServer
+from servicetest import EventPattern, call_async, tp_name_prefix, tp_path_prefix
+import dbus
+
+HANDLE_TYPE_NONE=0
+
+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])
+
+ # request a roomlist channel
+ EXPECTED_ROOM = tp_path_prefix + '/Connection/idle/irc/test_40localhost/RoomListChannel0'
+ call_async(q, conn, 'RequestChannel',
+ tp_name_prefix + '.Channel.Type.RoomList', HANDLE_TYPE_NONE,
+ 0, True)
+ ret = q.expect('dbus-return', method='RequestChannel')
+ assert EXPECTED_ROOM == ret.value[0]
+
+ # verify that a new channel was created and signalled
+ q.expect('dbus-signal', signal='NewChannels',
+ args=[[(EXPECTED_ROOM,
+ { tp_name_prefix + u'.Channel.ChannelType':
+ tp_name_prefix + u'.Channel.Type.RoomList',
+ tp_name_prefix + u'.Channel.TargetHandle': 0,
+ tp_name_prefix + u'.Channel.TargetHandleType': 0})]])
+ q.expect('dbus-signal', signal='NewChannel',
+ args=[tp_path_prefix + '/Connection/idle/irc/test_40localhost/RoomListChannel0',
+ tp_name_prefix + u'.Channel.Type.RoomList', 0, 0, 1])
+
+ # try to request another roomlist channel
+ call_async(q, conn, 'RequestChannel',
+ tp_name_prefix + '.Channel.Type.RoomList', HANDLE_TYPE_NONE,
+ 0, True)
+ ret = q.expect('dbus-return', method='RequestChannel')
+ # assert that it returns the same channel
+ assert EXPECTED_ROOM == ret.value[0]
+
+ call_async(q, conn, 'Disconnect')
+ q.expect_many(
+ EventPattern('dbus-return', method='Disconnect'),
+ EventPattern('dbus-signal', signal='ChannelClosed', args=[EXPECTED_ROOM]),
+ EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1]))
+ return True
+
+if __name__ == '__main__':
+ exec_test(test)
+
More information about the telepathy-commits
mailing list