aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-14 20:14:03 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-14 20:14:03 +0200
commit38a69dc35aacd60125b398b6a85ee7273db02797 (patch)
tree2f09ded980c3a7f09e508a0ae0476bb1c99ca936 /bot/Reminder/run_test.py
parentImprove Supybot tests, fix bugs found in the process (diff)
downloadcouncil-webapp-38a69dc35aacd60125b398b6a85ee7273db02797.tar.gz
council-webapp-38a69dc35aacd60125b398b6a85ee7273db02797.tar.bz2
council-webapp-38a69dc35aacd60125b398b6a85ee7273db02797.zip
Reminder plugin more testable + tests for it
Diffstat (limited to 'bot/Reminder/run_test.py')
-rw-r--r--bot/Reminder/run_test.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/bot/Reminder/run_test.py b/bot/Reminder/run_test.py
new file mode 100644
index 0000000..73bc394
--- /dev/null
+++ b/bot/Reminder/run_test.py
@@ -0,0 +1,28 @@
+import unittest
+from plugin import Reminder
+import urllib
+import time
+
+class FakeIrc:
+ msgs = []
+
+ def sendMsg(self, msg):
+ self.msgs.append(msg)
+
+def do_nothing():
+ pass
+class TestSequenceFunctions(unittest.TestCase):
+ def test_ping_with_newer_stamp(self):
+ logger = FakeIrc()
+ testee = Reminder(logger, sleep = 0)
+ testee.get_data = do_nothing
+ testee.data = {"users":["nick1","nick2"],"remind_time":u"Wed Jun 08 20:15:04 2011","message":u"Test message"}
+ time.sleep(1)
+ assert(len(logger.msgs) == 2)
+ for i in range(2):
+ assert(logger.msgs[i].command == 'PRIVMSG')
+ assert(logger.msgs[i].args[0] == 'nick' + str(i+1))
+ assert(logger.msgs[i].args[1] == u"Test message")
+
+if __name__ == '__main__':
+ unittest.main()