fix Encyclopedia testcases.
This commit is contained in:
@ -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
|
||||
|
@ -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 <reply> 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 <reply> Hi, welcome to $chan!')
|
||||
self.assertResponse('hello', 'Hi, welcome to #test!')
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 tabstop=4 expandtab textwidth=100:
|
||||
|
Reference in New Issue
Block a user