aboutsummaryrefslogtreecommitdiff
path: root/bot/tests
diff options
context:
space:
mode:
Diffstat (limited to 'bot/tests')
-rw-r--r--bot/tests/run_test.py68
-rw-r--r--bot/tests/test_meeting.py16
2 files changed, 45 insertions, 39 deletions
diff --git a/bot/tests/run_test.py b/bot/tests/run_test.py
index f4e6e49..2b6c6f3 100644
--- a/bot/tests/run_test.py
+++ b/bot/tests/run_test.py
@@ -344,40 +344,44 @@ class MeetBotTest(unittest.TestCase):
"""
test = test_meeting.TestMeeting()
- test.M.config.manage_agenda = True
test.set_voters(['x', 'z'])
test.set_agenda([['first item', ['opt1', 'opt2']], ['second item', []]])
- test.process("""
- 20:13:50 <x> #startmeeting
- 20:13:50 <x> #nextitem
- 20:13:50 <x> #nextitem
- 20:13:50 <x> #previtem
- 20:13:50 <x> #previtem
- 20:13:50 <x> #startvote
- 20:13:50 <x> #vote 10
- 20:13:50 <x> #vote 1
- 20:13:50 <y> #vote 0
- 20:13:50 <z> #vote 0
- 20:13:50 <x> #endvote
- 20:13:50 <x> #endmeeting""")
-
-
- answers = ['Current agenda item is second item.',
- 'Current agenda item is second item.',
- 'Current agenda item is first item.',
- 'Current agenda item is first item.',
- 'Voting started. Your choices are: ',
- '0. first item',
- "1. ['opt1', 'opt2']",
- ' Vote #vote <option number>.',
- ' End voting with #endvote.',
- 'Your vote was out of range!',
- "You voted for #1 - ['opt1', 'opt2']",
- 'You can not vote. Only x, z can vote',
- 'You voted for #0 - first item']
-
- self.assert_(test.votes == {'first item': {u'x': 'opt2', u'z': 'opt1'}, 'second item': {}})
- self.assert_(test.log[0:len(answers)] == answers)
+
+
+ # Test starting meeting. Enable agenda management after that
+ test.answer_should_match("20:13:50 <x> #startmeeting",
+ "Meeting started .*\nUseful Commands: #action #agreed #help #info #idea #link #topic.\n")
+ test.M.config.manage_agenda = True
+
+ # Test moving through items
+ test.answer_should_match('20:13:50 <x> #nextitem', 'Current agenda item is second item.')
+ test.answer_should_match('20:13:50 <x> #nextitem', 'Current agenda item is second item.')
+ test.answer_should_match('20:13:50 <x> #previtem', 'Current agenda item is first item.')
+ test.answer_should_match('20:13:50 <x> #previtem', 'Current agenda item is first item.')
+
+ # Test voting
+ test.answer_should_match('20:13:50 <x> #startvote', 'Voting started\. ' +\
+ 'Your choices are:\n0. opt1\n1. opt2\nVote ' +\
+ '#vote <option number>.\nEnd voting with #endvote.')
+ test.answer_should_match('20:13:50 <x> #startvote', 'Voting is already open. ' +\
+ 'You can end it with #endvote.')
+ test.answer_should_match('20:13:50 <x> #vote 10', 'Your vote was out of range\!')
+ test.answer_should_match('20:13:50 <x> #vote 1', 'You voted for #1 - opt2')
+ test.answer_should_match('20:13:50 <x> #vote 0', 'You voted for #0 - opt1')
+ test.answer_should_match('20:13:50 <x> #vote 0', 'You voted for #0 - opt1')
+ test.answer_should_match('20:13:50 <x> #nextitem', 'Voting is currently ' +\
+ 'open so I didn\'t change item. Please #endvote first')
+ test.answer_should_match('20:13:50 <x> #previtem', 'Voting is currently ' +\
+ 'open so I didn\'t change item. Please #endvote first')
+ test.answer_should_match('20:13:50 <x> #endvote', 'Voting closed.')
+ test.answer_should_match('20:13:50 <x> #endvote', 'Voting is already closed. ' +\
+ 'You can start it with #startvote.')
+
+ test.M.config.manage_agenda = False
+ test.answer_should_match('20:13:50 <x> #endmeeting', 'Meeting ended ' +\
+ '.*\nMinutes:.*\nMinutes \(text\):.*\nLog:.*')
+
+ assert(test.votes() == {'first item': {u'x': 'opt2', u'z': 'opt1'}, 'second item': {}})
if __name__ == '__main__':
os.chdir(os.path.join(os.path.dirname(__file__), '.'))
diff --git a/bot/tests/test_meeting.py b/bot/tests/test_meeting.py
index 9315b63..78bd2dc 100644
--- a/bot/tests/test_meeting.py
+++ b/bot/tests/test_meeting.py
@@ -2,13 +2,6 @@ import ircmeeting.meeting as meeting
import ircmeeting.writers as writers
import re
import time
-def process_meeting(contents, extraConfig={}, dontSave=True,
- filename='/dev/null'):
- """Take a test script, return Meeting object of that meeting.
-
- To access the results (a dict keyed by extensions), use M.save(),
- with M being the return of this function.
- """
class TestMeeting:
logline_re = re.compile(r'\[?([0-9: ]*)\]? *<[@+]?([^>]+)> *(.*)')
loglineAction_re = re.compile(r'\[?([0-9: ]*)\]? *\* *([^ ]+) *(.*)')
@@ -57,5 +50,14 @@ class TestMeeting:
line = m.group(3).strip()
self.M.addline(nick, "ACTION "+line, time_=time_)
+ def answer_should_match(self, line, answer_regexp):
+ self.log = []
+ self.process(line)
+ answer = '\n'.join(self.log)
+ error_msg = "Answer for:\n\t'" + line + "'\n was \n\t'" + answer +\
+ "'\ndid not match regexp\n\t'" + answer_regexp + "'"
+ answer_matches = re.match(answer_regexp, answer)
+ assert answer_matches, error_msg
+
def votes(self):
return(self.M.config.agenda._votes)