Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/test.py
diff options
context:
space:
mode:
authorRichard Darst <rkd@zgib.net>2009-08-07 23:24:05 (GMT)
committer Richard Darst <rkd@zgib.net>2009-08-07 23:24:05 (GMT)
commitfb8b0a902e95a4d77dc84ba316d0deff6106d0f6 (patch)
tree57d56afff33880e2832b785694efa59882829bde /test.py
parent0c936f7cd88c5e001ffccf69271b6a877a82fa3d (diff)
Add comprehensive test suite
- Enter via tests/run_tests.py - It has two parts: it replays two meetings, just being sure no exceptions are raised - It runs one suite of test commands through supybot, using the supybot test suite, to ensure that supybot usage works. darcs-hash:20090807232405-82ea9-327d27a3709ad8f851a51552b13d286a9a118fc3.gz
Diffstat (limited to 'test.py')
-rw-r--r--test.py45
1 files changed, 44 insertions, 1 deletions
diff --git a/test.py b/test.py
index b1ef38d..e42d601 100644
--- a/test.py
+++ b/test.py
@@ -30,8 +30,51 @@
from supybot.test import *
-class MeetBotTestCase(PluginTestCase):
+import os
+import sys
+
+class MeetBotTestCase(ChannelPluginTestCase):
+ channel = "#testchannel"
plugins = ('MeetBot',)
+ def testRunMeeting(self):
+ test_script = file(os.path.join(os.path.dirname(__file__),
+ "tests/test-script-2.log.txt"))
+ for line in test_script:
+ # Normalize input lines somewhat.
+ line = line.strip()
+ if not line: continue
+ # This consists of input/output pairs we expect. If it's
+ # not here, it's not checked for.
+ match_pairs = (('#startmeeting', 'Meeting started'),
+ ('#endmeeting', 'Meeting ended'),
+ ('#topic (.*)', 1),
+ ('#meetingtopic (.*)', 1),
+ ('#meetingname','The meeting name has been set to'),
+ ('#chair', 'Current chairs:'),
+ ('#unchair', 'Current chairs:'),
+ )
+ # Run the command and get any possible output
+ reply = [ ]
+ self.feedMsg(line)
+ r = self.irc.takeMsg()
+ while r:
+ reply.append(r.args[1])
+ r = self.irc.takeMsg()
+ reply = "\n".join(reply)
+ # If our input line matches a test pattern, then insist
+ # that the output line matches the expected output
+ # pattern.
+ for test in match_pairs:
+ if re.search(test[0], line):
+ groups = re.search(test[0], line).groups()
+ # Output pattern depends on input pattern
+ if isinstance(test[1], int):
+ assert re.search(re.escape(groups[test[1]-1]),
+ reply), 'line "%s" gives output "%s"'%(line, reply)
+ # Just match the given pattern.
+ else:
+ assert re.search(test[1], reply), 'line "%s" gives output "%s"'%(line, reply)
+
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: