fix Encyclopedia testcases.
This commit is contained in:
parent
ed91a8a426
commit
4eeb6ddc7f
|
@ -23,6 +23,7 @@ import supybot.ircdb as ircdb
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
|
import supybot.world as world
|
||||||
import sys, os, re, hashlib, random, time
|
import sys, os, re, hashlib, random, time
|
||||||
|
|
||||||
if sys.version_info >= (2, 5, 0):
|
if sys.version_info >= (2, 5, 0):
|
||||||
|
@ -83,6 +84,11 @@ class FactoidSet:
|
||||||
# Repeat filtering message queue
|
# Repeat filtering message queue
|
||||||
msgcache = {}
|
msgcache = {}
|
||||||
def queue(irc, to, msg):
|
def queue(irc, to, msg):
|
||||||
|
if world.testing:
|
||||||
|
# don't mess up testcases
|
||||||
|
irc.queueMsg(ircmsgs.privmsg(to, msg))
|
||||||
|
return
|
||||||
|
|
||||||
now = time.time()
|
now = time.time()
|
||||||
for m in msgcache.keys():
|
for m in msgcache.keys():
|
||||||
if msgcache[m] < now - 30:
|
if msgcache[m] < now - 30:
|
||||||
|
@ -101,7 +107,6 @@ def queue(irc, to, msg):
|
||||||
def capab(prefix, capability):
|
def capab(prefix, capability):
|
||||||
# too bad people don't use supybot's own methods,
|
# too bad people don't use supybot's own methods,
|
||||||
# it would save me the trouble of hacking this up.
|
# it would save me the trouble of hacking this up.
|
||||||
import supybot.world as world
|
|
||||||
if world.testing:
|
if world.testing:
|
||||||
# we're running a testcase, return always True.
|
# we're running a testcase, return always True.
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -23,14 +23,14 @@ import supybot.conf as conf
|
||||||
Econf = conf.supybot.plugins.Encyclopedia
|
Econf = conf.supybot.plugins.Encyclopedia
|
||||||
Econf.prefixchar.set('@')
|
Econf.prefixchar.set('@')
|
||||||
|
|
||||||
# we use PluginTestCase instead of ChannelPluginTestCase, Encyclopedia does some weird parsing stuff
|
|
||||||
# that upset testcases.
|
class EncyclopediaTestCase(ChannelPluginTestCase):
|
||||||
class EncyclopediaTestCase(PluginTestCase):
|
|
||||||
plugins = ('Encyclopedia',)
|
plugins = ('Encyclopedia',)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(EncyclopediaTestCase, self).setUp()
|
super(EncyclopediaTestCase, self).setUp()
|
||||||
conf.supybot.reply.whenNotCommand.setValue(False)
|
conf.supybot.reply.whenNotCommand.setValue(False)
|
||||||
|
self.createDB()
|
||||||
|
|
||||||
def createDB(self):
|
def createDB(self):
|
||||||
import sqlite, os
|
import sqlite, os
|
||||||
|
@ -65,14 +65,19 @@ class EncyclopediaTestCase(PluginTestCase):
|
||||||
break
|
break
|
||||||
return cb
|
return cb
|
||||||
|
|
||||||
def testSimpleTest(self):
|
def testAdd(self):
|
||||||
self.createDB()
|
self.assertNotError('foo is bar')
|
||||||
self.assertNotError('test is test')
|
self.assertResponse('foo', 'foo is bar')
|
||||||
self.assertResponse('test', 'test is test')
|
|
||||||
self.assertNotError('no, test is test1')
|
def testEdit(self):
|
||||||
self.assertResponse('test', 'test is test1')
|
self.assertNotError('foo is bar')
|
||||||
self.assertNoResponse('hello is <reply> Hi, welcome to $chan!') # no reply? why?
|
self.assertNotError('no, foo is bar1')
|
||||||
self.assertResponse('hello', 'Hi, welcome to test!')
|
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:
|
# vim:set shiftwidth=4 softtabstop=4 tabstop=4 expandtab textwidth=100:
|
||||||
|
|
Loading…
Reference in New Issue