2015-07-08 03:07:20 +02:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
|
|
|
|
import classes
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
class TestFakeIRC(unittest.TestCase):
|
|
|
|
def setUp(self):
|
2015-08-29 18:39:33 +02:00
|
|
|
self.irc = classes.FakeIRC('unittest', classes.FakeProto())
|
2015-07-08 03:07:20 +02:00
|
|
|
|
|
|
|
def testFakeIRC(self):
|
|
|
|
self.irc.run('this should do nothing')
|
|
|
|
self.irc.send('ADD this message')
|
|
|
|
self.irc.send(':add THIS message too')
|
|
|
|
msgs = self.irc.takeMsgs()
|
|
|
|
self.assertEqual(['ADD this message', ':add THIS message too'],
|
|
|
|
msgs)
|
|
|
|
# takeMsgs() clears cached messages queue, so the next call should
|
|
|
|
# return an empty list.
|
|
|
|
msgs = self.irc.takeMsgs()
|
|
|
|
self.assertEqual([], msgs)
|
|
|
|
|
|
|
|
def testFakeIRCtakeCommands(self):
|
|
|
|
msgs = ['ADD this message', ':9PY THIS message too']
|
|
|
|
self.assertEqual(['ADD', 'THIS'], self.irc.takeCommands(msgs))
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|