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
This commit is contained in:
parent
328cf6e92f
commit
e8c2f57e51
45
test.py
45
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:
|
||||
|
27
tests/run_test.py
Normal file
27
tests/run_test.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Richard Darst, 2009
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
run_tests = True
|
||||
os.chdir(os.path.join(os.path.dirname(__file__), '.'))
|
||||
|
||||
print sys.path
|
||||
sys.path.insert(0, "..")
|
||||
|
||||
sys.argv[1:] = ["replay", "test-script-1.log.txt"]
|
||||
execfile("../meeting.py")
|
||||
|
||||
del sys.path[0]
|
||||
|
||||
|
||||
# Supybot-based tests
|
||||
|
||||
os.symlink("..", "MeetBot")
|
||||
try:
|
||||
sys.argv[1:] = ["./MeetBot"]
|
||||
execfile("/usr/bin/supybot-test")
|
||||
finally:
|
||||
os.unlink("MeetBot")
|
||||
|
||||
|
77
tests/test-script-1.log.txt
Normal file
77
tests/test-script-1.log.txt
Normal file
@ -0,0 +1,77 @@
|
||||
20:13:46 <MrBeige> #startmeeting
|
||||
|
||||
20:13:50 <T-Rex> #info this command is just before the first topic
|
||||
|
||||
20:13:50 <T-Rex> #topic Test of topics
|
||||
20:13:50 <T-Rex> #topic Second topic
|
||||
20:13:50 <T-Rex> #meetingtopic the meeting topic
|
||||
20:13:50 <T-Rex> #topic With áccents
|
||||
|
||||
|
||||
20:13:50 <MrBeige> #topic General command tests
|
||||
|
||||
20:13:50 <MrBeige> #accepted we will include this new format if we so choose.
|
||||
20:13:50 <MrBeige> #rejected we will not include this new format.
|
||||
20:13:50 <MrBeige> #chair Utahraptor T-Rex not-here
|
||||
20:13:50 <MrBeige> #chair Utahraptor T-Rex
|
||||
20:13:50 <MrBeige> #nick someone-not-present
|
||||
20:13:50 <MrBeige> #chair áccents
|
||||
20:13:50 <MrBeige> #nick áccenẗs
|
||||
20:13:50 <MrBeige> #unchar not-here
|
||||
|
||||
# all commands
|
||||
20:13:50 <MrBeige> #topic Test of all commands with different arguments
|
||||
20:13:50 <MrBeige> #topic
|
||||
20:13:50 <MrBeige> #idea
|
||||
20:13:50 <MrBeige> #info
|
||||
20:13:50 <MrBeige> #action
|
||||
20:13:50 <MrBeige> #agreed
|
||||
20:13:50 <MrBeige> #halp
|
||||
20:13:50 <MrBeige> #accepted
|
||||
20:13:50 <MrBeige> #rejected
|
||||
|
||||
20:13:50 <MrBeige> #topic Commands with non-ascii
|
||||
20:13:50 <MrBeige> #topic üáç€
|
||||
20:13:50 <MrBeige> #idea üáç€
|
||||
20:13:50 <MrBeige> #info üáç€
|
||||
20:13:50 <MrBeige> #action üáç€
|
||||
20:13:50 <MrBeige> #agreed üáç€
|
||||
20:13:50 <MrBeige> #halp üáç€
|
||||
20:13:50 <MrBeige> #accepted üáç€
|
||||
20:13:50 <MrBeige> #rejected üáç€
|
||||
|
||||
|
||||
20:13:50 <MrBeige> #item blah
|
||||
20:13:50 <MrBeige> #idea blah
|
||||
20:13:50 <MrBeige> #action blah
|
||||
20:13:50 <Utahraptor> #agreed blah
|
||||
|
||||
# escapes
|
||||
20:13:50 <MrBeige> #topic Escapes
|
||||
20:13:50 <Utahraptor> #nick <b>
|
||||
20:13:50 <Utahraptor> #nick **
|
||||
20:13:50 <Utahraptor> #idea blah_ blah_ ReST link reference...
|
||||
20:13:50 <ReST1_> #idea blah blah blah
|
||||
20:13:50 <ReST2_> this is some text
|
||||
20:13:50 <ReST2_> #idea under_score
|
||||
20:13:50 <Re_ST> #idea under_score
|
||||
20:13:50 <Re_ST> #idea under1_1score
|
||||
20:13:50 <Re_ST> #idea under1_score
|
||||
20:13:50 <Re_ST> #idea under_1score
|
||||
20:13:50 <Re_ST> #idea under-_score
|
||||
20:13:50 <Re_ST> #idea under_-score
|
||||
|
||||
# links
|
||||
20:13:50 <MrBeige> #topic Links
|
||||
20:13:50 <Utahraptor> #link http://test<b>.zgib.net
|
||||
20:13:50 <Utahraptor> #link http://test.zgib.net/&testpage
|
||||
|
||||
# accents
|
||||
20:13:50 <MrBeige> #topic Character sets
|
||||
20:13:50 <Üţáhraptõr> Nick with accents.
|
||||
20:13:50 <Üţáhraptõr> #idea Nick with accents.
|
||||
|
||||
# actions in actions
|
||||
#
|
||||
|
||||
20:13:52 <MrBeige> #endmeeting
|
39
tests/test-script-2.log.txt
Normal file
39
tests/test-script-2.log.txt
Normal file
@ -0,0 +1,39 @@
|
||||
#startmeeting
|
||||
this is a test line
|
||||
hi
|
||||
blah
|
||||
#topic play with chairs some
|
||||
#chair Hydroxide
|
||||
#chair h01ger
|
||||
#unchair Hydroxide
|
||||
#topic test action items
|
||||
something to say
|
||||
#action MrBeige does something
|
||||
#action h01ger and MrBeige do something else
|
||||
#action NickThatIsntHere does something
|
||||
#action MrGreen acts awesome
|
||||
#nick MrGreen
|
||||
#topic test other commands
|
||||
#info no I won't
|
||||
#idea blah
|
||||
#link http://www.debian.org
|
||||
http://www.debian.org
|
||||
/me says hi
|
||||
#topic try to cause some problems
|
||||
evil code to mess up html <b><i><u>
|
||||
#info evil code to mess up html <b><i><u>
|
||||
#nick
|
||||
#nick
|
||||
#chair
|
||||
#chair
|
||||
#unchair
|
||||
#info
|
||||
#info
|
||||
#idea
|
||||
#idea
|
||||
#topic test removing item from the minutes (nothing should be here)
|
||||
#info this shouldn't appear in the minutes
|
||||
#undo
|
||||
#endmeeting
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user