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
parent 0fb4dd6dff
commit 2e043ce19f

View File

@ -31,11 +31,10 @@
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):
@ -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"')