1
|
|
|
''' |
2
|
|
|
Created on May 10, 2012 |
3
|
|
|
|
4
|
|
|
@author: smotko |
5
|
|
|
''' |
6
|
|
|
from handler import Bot |
7
|
|
|
from logic import BotLogic |
8
|
|
|
|
9
|
|
|
import unittest |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class BotTest(unittest.TestCase): |
13
|
|
|
|
14
|
|
|
def setUp(self): |
15
|
|
|
self.bot = Bot() |
16
|
|
|
self.logic = BotLogic(self.bot) |
17
|
|
|
|
18
|
|
|
def test_parse_priv_msg(self): |
19
|
|
|
line = ":[email protected] " \ |
20
|
|
|
+ "PRIVMSG #psywerx :I will try to improve my tunapasta " \ |
21
|
|
|
+ "from this data :P" |
22
|
|
|
nick, msg, _ = self.logic.parse_msg(line) |
23
|
|
|
self.assertEqual("HairyFotr", nick, "Nick does not match") |
24
|
|
|
self.assertEqual("I will try to improve my tunapasta " |
25
|
|
|
+ "from this data :P", msg, "Msg does not match") |
26
|
|
|
|
27
|
|
|
def test_parse_event(self): |
28
|
|
|
line = ":[email protected] QUIT " \ |
29
|
|
|
+ ":Quit: smotko" |
30
|
|
|
nick, msg, _ = self.logic.parse_msg(line) |
31
|
|
|
self.assertEqual("smotko", nick) |
32
|
|
|
self.assertEqual("Quit: smotko", msg) |
33
|
|
|
|
34
|
|
|
def test_parse_weird(self): |
35
|
|
|
line = ":smotko!~smotko@2001:1470:fffe:fe01:4c8b:3839:ad5f:3bbb " \ |
36
|
|
|
+ "JOIN #smotko-testing" |
37
|
|
|
nick, msg, channel = self.logic.parse_msg(line) |
38
|
|
|
self.assertEqual("smotko", nick) |
39
|
|
|
self.assertEqual("#smotko-testing", channel) |
40
|
|
|
|
41
|
|
|
if __name__ == "__main__": |
42
|
|
|
# import sys;sys.argv = ['', 'Test.testName'] |
43
|
|
|
unittest.main() |
44
|
|
|
|