[Telepathy-commits] [telepathy-idle/master] Add a regression test for messages delivered in proper order

Jonathon Jongsma jonathon.jongsma at collabora.co.uk
Fri Feb 13 17:43:16 PST 2009


There was a bug where messages that were queued in the same message timeout
(currently 2s) were not delivered in the order they were received.  This bug has
been fixed, but I thought it would be useful to add a regression test for it.
---
 tests/twisted/Makefile.am               |    1 +
 tests/twisted/idletest.py               |    2 +-
 tests/twisted/messages/message-order.py |   53 +++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 1 deletions(-)
 create mode 100644 tests/twisted/messages/message-order.py

diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 2168c9c..0572a71 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -4,6 +4,7 @@ TWISTED_TESTS = \
 		connect/connect-fail.py \
 		connect/connect-fail-ssl.py \
 		channels/join-muc-channel.py \
+		messages/message-order.py \
 		$(NULL)
 
 TESTS =
diff --git a/tests/twisted/idletest.py b/tests/twisted/idletest.py
index 8db3f5c..f5c2d1a 100644
--- a/tests/twisted/idletest.py
+++ b/tests/twisted/idletest.py
@@ -52,7 +52,7 @@ class BaseIRCServer(irc.IRC):
         print ("data received: %s" % (data,))
         (prefix, command, args) = irc.parsemsg(data)
         if command == 'PRIVMSG':
-            self.event_func(make_privmsg_event(args[0], ' '.join(args[1:])))
+            self.event_func(make_privmsg_event(args[0], ' '.join(args[1:]).rstrip('\r\n')))
         #handle 'login' handshake
         elif command == 'PASS':
             self.passwd = args[0]
diff --git a/tests/twisted/messages/message-order.py b/tests/twisted/messages/message-order.py
new file mode 100644
index 0000000..68dfd11
--- /dev/null
+++ b/tests/twisted/messages/message-order.py
@@ -0,0 +1,53 @@
+
+"""
+Test that messages that are sent within the same message delivery timeout
+(default 2s) get delivered in the proper order.  This bug was fixed in rev
+8fae4404798, this is just a regression test to ensure that it stays fixed
+"""
+
+from idletest import exec_test
+from servicetest import EventPattern, call_async
+import dbus
+
+def test(q, bus, conn, stream):
+    conn.Connect()
+    q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+    CHANNEL_NAME = '#idletest'
+    room_handles = conn.RequestHandles(2, [CHANNEL_NAME])
+    call_async(q, conn, 'RequestChannel', 'org.freedesktop.Telepathy.Channel.Type.Text', 2, room_handles[0], True)
+
+    ret = q.expect('dbus-return', method='RequestChannel')
+    q.expect('dbus-signal', signal='MembersChanged')
+    chan = bus.get_object(conn.bus_name, ret.value[0])
+
+    text_chan = dbus.Interface(chan,
+        u'org.freedesktop.Telepathy.Channel.Type.Text')
+    # send a whole bunch of messages in a row
+    call_async(q, text_chan, 'Send', 0, '0')
+    call_async(q, text_chan, 'Send', 0, '1')
+    call_async(q, text_chan, 'Send', 0, '2')
+    call_async(q, text_chan, 'Send', 0, '3')
+    call_async(q, text_chan, 'Send', 0, '4')
+    call_async(q, text_chan, 'Send', 0, '5')
+    call_async(q, text_chan, 'Send', 0, '6')
+    call_async(q, text_chan, 'Send', 0, '7')
+    call_async(q, text_chan, 'Send', 0, '8')
+    call_async(q, text_chan, 'Send', 0, '9')
+
+    q.expect('irc-privmsg', data={'message':'0','recipient':CHANNEL_NAME})
+    q.expect('irc-privmsg', data={'message':'1','recipient':CHANNEL_NAME})
+    q.expect('irc-privmsg', data={'message':'2','recipient':CHANNEL_NAME})
+    q.expect('irc-privmsg', data={'message':'3','recipient':CHANNEL_NAME})
+    q.expect('irc-privmsg', data={'message':'4','recipient':CHANNEL_NAME})
+    q.expect('irc-privmsg', data={'message':'5','recipient':CHANNEL_NAME})
+    q.expect('irc-privmsg', data={'message':'6','recipient':CHANNEL_NAME})
+    q.expect('irc-privmsg', data={'message':'7','recipient':CHANNEL_NAME})
+    q.expect('irc-privmsg', data={'message':'8','recipient':CHANNEL_NAME})
+    q.expect('irc-privmsg', data={'message':'9','recipient':CHANNEL_NAME})
+
+    call_async(q, conn, 'Disconnect')
+    return True
+
+if __name__ == '__main__':
+    exec_test(test, timeout=10)
+
-- 
1.5.6.5




More information about the telepathy-commits mailing list