Made PRIVMSG and NOTICE low-priority so TOPIC would happen before them.

This commit is contained in:
Jeremy Fincher 2003-09-06 02:01:44 +00:00
parent c45e38b537
commit 3eb86b8869
2 changed files with 10 additions and 5 deletions

View File

@ -123,7 +123,7 @@ class IrcMsgQueue(object):
self.msgs.add(msg)
if msg.command in ('MODE', 'KICK', 'PONG'):
self.highpriority.enqueue(msg)
elif msg.command in ('PING', 'WHO'):
elif msg.command in ('PRIVMSG', 'PING', 'WHO', 'NOTICE'):
self.lowpriority.enqueue(msg)
else:
self.normal.enqueue(msg)

View File

@ -45,6 +45,7 @@ class IrcMsgQueueTestCase(unittest.TestCase):
kick = ircmsgs.kick('#foo', 'PeterB')
pong = ircmsgs.pong('123')
ping = ircmsgs.ping('123')
topic = ircmsgs.topic('#foo')
notice = ircmsgs.notice('jemfinch', 'supybot here')
join = ircmsgs.join('#foo')
who = ircmsgs.who('#foo')
@ -77,10 +78,7 @@ class IrcMsgQueueTestCase(unittest.TestCase):
q.enqueue(self.msg)
q.enqueue(self.kick)
self.assertEqual(self.kick, q.dequeue())
q.enqueue(self.ping)
q.enqueue(self.msg)
self.assertEqual(self.msg, q.dequeue())
self.assertEqual(self.ping, q.dequeue())
q.enqueue(self.ping)
q.enqueue(self.msgs[0])
q.enqueue(self.kick)
@ -88,9 +86,9 @@ class IrcMsgQueueTestCase(unittest.TestCase):
q.enqueue(self.mode)
self.assertEqual(self.kick, q.dequeue())
self.assertEqual(self.mode, q.dequeue())
self.assertEqual(self.ping, q.dequeue())
self.assertEqual(self.msgs[0], q.dequeue())
self.assertEqual(self.msgs[1], q.dequeue())
self.assertEqual(self.ping, q.dequeue())
def testNoIdenticals(self):
q = irclib.IrcMsgQueue()
@ -110,6 +108,13 @@ class IrcMsgQueueTestCase(unittest.TestCase):
self.assertEqual(self.join, q.dequeue())
self.assertEqual(self.who, q.dequeue())
def testTopicBeforePrivmsg(self):
q = irclib.IrcMsgQueue()
q.enqueue(self.msg)
q.enqueue(self.topic)
self.assertEqual(self.topic, q.dequeue())
self.assertEqual(self.msg, q.dequeue())
class ChannelTestCase(unittest.TestCase):
def testPickleCopy(self):