add rank test to factoids, update factoids test code to sqlite3

This commit is contained in:
nanotube 2010-03-23 13:54:31 -04:00 committed by Valentin Lorentz
parent 5c0596f484
commit b922890b6f

View File

@ -31,12 +31,11 @@
from supybot.test import * from supybot.test import *
try: try:
import sqlite import sqlite3
except ImportError: except ImportError:
sqlite = None from pysqlite2 import dbapi2 as sqlite3 # for python2.4
if sqlite: class FactoidsTestCase(ChannelPluginTestCase):
class FactoidsTestCase(ChannelPluginTestCase):
plugins = ('Factoids',) plugins = ('Factoids',)
def testRandomfactoid(self): def testRandomfactoid(self):
self.assertError('random') self.assertError('random')
@ -162,6 +161,13 @@ if sqlite:
conf.supybot.plugins.Factoids.\ conf.supybot.plugins.Factoids.\
replyWhenInvalidCommand.setValue(orig) replyWhenInvalidCommand.setValue(orig)
def testRank(self):
self.assertNotError('learn foo as bar')
self.assertNotError('learn moo as cow')
self.assertRegexp('factoids rank', '#1 foo \(0\), #2 moo \(0\)')
self.assertRegexp('whatis moo', '.*cow.*')
self.assertRegexp('factoids rank', '#1 moo \(1\), #2 foo \(0\)')
def testQuoteHandling(self): def testQuoteHandling(self):
self.assertNotError('learn foo as "\\"bar\\""') self.assertNotError('learn foo as "\\"bar\\""')
self.assertRegexp('whatis foo', r'"bar"') self.assertRegexp('whatis foo', r'"bar"')