[Telepathy-commits] [telepathy-idle/master] messages/leading-space.py: simplify this test significantly
Jonathon Jongsma
jonathon.jongsma at collabora.co.uk
Tue Feb 17 10:06:27 PST 2009
wjt questioned the need for the subclassed server in his review and eliminating
the server actually makes things much simpler. At the same time, I realized
that there's really no need for the user to join a chat room in order to test
out this behavior, so remove that whole piece and just send a privmsg directly
and test whether it is parsed correctly.
---
tests/twisted/idletest.py | 1 +
tests/twisted/messages/leading-space.py | 43 +++++++-----------------------
2 files changed, 11 insertions(+), 33 deletions(-)
diff --git a/tests/twisted/idletest.py b/tests/twisted/idletest.py
index e4fa737..ab98a44 100644
--- a/tests/twisted/idletest.py
+++ b/tests/twisted/idletest.py
@@ -91,6 +91,7 @@ class BaseIRCServer(irc.IRC):
def dataReceived(self, data):
self.log ("data received: %s" % (data,))
(_prefix, _command, _args) = irc.parsemsg(data)
+ self.event_func(make_irc_event('stream-%s' % _command, _args))
try:
f = getattr(self, 'handle%s' % _command)
try:
diff --git a/tests/twisted/messages/leading-space.py b/tests/twisted/messages/leading-space.py
index ce24c76..e14a87f 100644
--- a/tests/twisted/messages/leading-space.py
+++ b/tests/twisted/messages/leading-space.py
@@ -7,49 +7,26 @@ recently fixed
from idletest import exec_test, BaseIRCServer
from servicetest import EventPattern, call_async
+from constants import *
import dbus
MESSAGE_WITH_LEADING_SPACE=' This is a message with a leading space'
-class LeadingSpaceIRCServer(BaseIRCServer):
- remoteuser = 'remoteuser'
-
- def handlePRIVMSG(self, args, prefix):
- #chain up to the base class implementation which simply signals a privmsg event
- BaseIRCServer.handlePRIVMSG(self, args, prefix)
- sender = prefix
- recipient = args[0]
- self.sendMessage('PRIVMSG', recipient, ':%s' % MESSAGE_WITH_LEADING_SPACE, prefix=self.remoteuser)
-
- def handleJOIN(self, args, prefix):
- room = args[0]
- self.sendMessage('JOIN', room, prefix=self.nick)
- self._sendNameReply(room, [self.nick, self.remoteuser])
-
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 message
- call_async(q, text_chan, 'Send', 0, 'foo')
- q.expect('irc-privmsg')
- # the test server above is rigged to send a reply message with a leading
- # space in response to our PRIVMSG. If telepathy-idle parses this message
- # correctly, we should emit a 'Received' signal
- q.expect('dbus-signal', signal='Received', predicate=lambda x: x.args[5]==MESSAGE_WITH_LEADING_SPACE)
+
+ # send a message with a leading space
+ stream.sendMessage('PRIVMSG', stream.nick,
+ ':%s' % MESSAGE_WITH_LEADING_SPACE, prefix='remoteuser')
+ # If telepathy-idle parses this message correctly, it should emit a
+ # 'Received' signal
+ q.expect('dbus-signal', signal='Received',
+ predicate=lambda x: x.args[5]==MESSAGE_WITH_LEADING_SPACE)
call_async(q, conn, 'Disconnect')
return True
if __name__ == '__main__':
- exec_test(test, protocol=LeadingSpaceIRCServer)
+ exec_test(test)
--
1.5.6.5
More information about the telepathy-commits
mailing list