From fb8b0a902e95a4d77dc84ba316d0deff6106d0f6 Mon Sep 17 00:00:00 2001 From: Richard Darst Date: Fri, 07 Aug 2009 23:24:05 +0000 Subject: 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 --- (limited to 'test.py') 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: -- cgit v0.9.1