aboutsummaryrefslogtreecommitdiff
path: root/bot/tests
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-22 09:28:20 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-22 20:31:35 +0200
commit62b3ba6efe4ac1de77f24527e844c9a70ed94b1b (patch)
tree10b735cb58d407ddcbd32a97bdfc68eb8eab0de6 /bot/tests
parentMerge remote-tracking branch 'github/new_bot_commands' (diff)
downloadcouncil-webapp-62b3ba6efe4ac1de77f24527e844c9a70ed94b1b.tar.gz
council-webapp-62b3ba6efe4ac1de77f24527e844c9a70ed94b1b.tar.bz2
council-webapp-62b3ba6efe4ac1de77f24527e844c9a70ed94b1b.zip
Add support for #timelimit (add|list|remove) commands
Diffstat (limited to 'bot/tests')
-rw-r--r--bot/tests/run_test.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/bot/tests/run_test.py b/bot/tests/run_test.py
index 9808ee6..e3a9030 100644
--- a/bot/tests/run_test.py
+++ b/bot/tests/run_test.py
@@ -6,6 +6,8 @@ import re
import shutil
import sys
import tempfile
+import time
+import threading
import unittest
os.environ['MEETBOT_RUNNING_TESTS'] = '1'
@@ -427,6 +429,60 @@ class MeetBotTest(unittest.TestCase):
assert(test.votes() == {'first item': {u'x': 'opt2', u'z': 'opt1'}, 'second item': {}})
+ def test_agenda_time_limit_adding(self):
+ test = self.get_simple_agenda_test()
+ test.answer_should_match('20:13:50 <x> #timelimit', 'Usage "#timelimit ' +\
+ 'add <minutes>:<seconds> <message>" or "' +\
+ '#timelimit list" or "#timelimit remove ' +\
+ '<message>"')
+ test.answer_should_match('20:13:50 <x> #timelimit add 0:1 some other message',
+ 'Added "some other message" reminder in 0:1')
+ test.answer_should_match('20:13:50 <x> #timelimit add 1:0 some message',
+ 'Added "some message" reminder in 1:0')
+ time.sleep(2)
+ last_message = test.log[-1]
+ assert(last_message == 'some other message')
+ reminders = test.M.config.agenda.reminders
+ assert(len(reminders) == 2)
+ for reminder in reminders.values():
+ assert(reminder.__class__ == threading._Timer)
+
+ test.process('20:13:50 <x> #nextitem')
+
+ def test_agenda_time_limit_removing_when_changing_item(self):
+ test = self.get_simple_agenda_test()
+
+ test.process('20:13:50 <x> #timelimit add 0:1 message')
+ assert(len(test.M.config.agenda.reminders) == 1)
+ test.process('20:13:50 <x> #nextitem')
+ assert(len(test.M.config.agenda.reminders) == 0)
+ test.process('20:13:50 <x> #timelimit add 0:1 message')
+ assert(len(test.M.config.agenda.reminders) == 1)
+ test.process('20:13:50 <x> #previtem')
+ assert(len(test.M.config.agenda.reminders) == 0)
+
+ def test_agenda_time_limit_manual_removing(self):
+ test = self.get_simple_agenda_test()
+
+ test.process('20:13:50 <x> #timelimit add 0:1 message')
+ test.process('20:13:50 <x> #timelimit add 0:1 other message')
+ keys = test.M.config.agenda.reminders.keys()
+ keys.sort()
+ assert(keys == ['message', 'other message'])
+
+ test.answer_should_match('20:13:50 <x> #timelimit remove other message', 'Reminder "other message" removed')
+ keys = test.M.config.agenda.reminders.keys()
+ assert(keys == ['message'])
+
+ def test_agenda_time_limit_listing(self):
+ test = self.get_simple_agenda_test()
+ test.process('20:13:50 <x> #timelimit add 0:1 message')
+ test.process('20:13:50 <x> #timelimit add 0:1 other message')
+ test.process('20:13:50 <x> #timelimit add 0:1 yet another message')
+ keys = test.M.config.agenda.reminders.keys()
+ test.answer_should_match('20:13:50 <x> #timelimit list',
+ 'Set reminders: "' + '", "'.join(keys) + '"')
+
if __name__ == '__main__':
os.chdir(os.path.join(os.path.dirname(__file__), '.'))