From 4eeb6ddc7fc21972cd3e7c5325b8858fa9ebae0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eli=C3=A1n=20Hanisch?= Date: Wed, 3 Aug 2011 18:33:46 -0300 Subject: [PATCH] fix Encyclopedia testcases. --- Encyclopedia/plugin.py | 7 ++++++- Encyclopedia/test.py | 27 ++++++++++++++++----------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Encyclopedia/plugin.py b/Encyclopedia/plugin.py index e6171be..f1145c2 100644 --- a/Encyclopedia/plugin.py +++ b/Encyclopedia/plugin.py @@ -23,6 +23,7 @@ import supybot.ircdb as ircdb import supybot.conf as conf import supybot.utils as utils import supybot.ircutils as ircutils +import supybot.world as world import sys, os, re, hashlib, random, time if sys.version_info >= (2, 5, 0): @@ -83,6 +84,11 @@ class FactoidSet: # Repeat filtering message queue msgcache = {} def queue(irc, to, msg): + if world.testing: + # don't mess up testcases + irc.queueMsg(ircmsgs.privmsg(to, msg)) + return + now = time.time() for m in msgcache.keys(): if msgcache[m] < now - 30: @@ -101,7 +107,6 @@ def queue(irc, to, msg): def capab(prefix, capability): # too bad people don't use supybot's own methods, # it would save me the trouble of hacking this up. - import supybot.world as world if world.testing: # we're running a testcase, return always True. return True diff --git a/Encyclopedia/test.py b/Encyclopedia/test.py index 8f8f4b8..dbeffee 100644 --- a/Encyclopedia/test.py +++ b/Encyclopedia/test.py @@ -23,14 +23,14 @@ import supybot.conf as conf Econf = conf.supybot.plugins.Encyclopedia Econf.prefixchar.set('@') -# we use PluginTestCase instead of ChannelPluginTestCase, Encyclopedia does some weird parsing stuff -# that upset testcases. -class EncyclopediaTestCase(PluginTestCase): + +class EncyclopediaTestCase(ChannelPluginTestCase): plugins = ('Encyclopedia',) def setUp(self): super(EncyclopediaTestCase, self).setUp() conf.supybot.reply.whenNotCommand.setValue(False) + self.createDB() def createDB(self): import sqlite, os @@ -65,14 +65,19 @@ class EncyclopediaTestCase(PluginTestCase): break return cb - def testSimpleTest(self): - self.createDB() - self.assertNotError('test is test') - self.assertResponse('test', 'test is test') - self.assertNotError('no, test is test1') - self.assertResponse('test', 'test is test1') - self.assertNoResponse('hello is Hi, welcome to $chan!') # no reply? why? - self.assertResponse('hello', 'Hi, welcome to test!') + def testAdd(self): + self.assertNotError('foo is bar') + self.assertResponse('foo', 'foo is bar') + + def testEdit(self): + self.assertNotError('foo is bar') + self.assertNotError('no, foo is bar1') + self.assertResponse('foo', 'foo is bar1') + + def testKeyword(self): + self.assertNotError('hello is Hi, welcome to $chan!') + self.assertResponse('hello', 'Hi, welcome to #test!') + # vim:set shiftwidth=4 softtabstop=4 tabstop=4 expandtab textwidth=100: