mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Made MoobotFactoids case insensitive, and added tests to make sure that
case-insensitivity works.
This commit is contained in:
parent
f0574da59a
commit
1b25a207bf
@ -205,7 +205,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||
return
|
||||
# Check the factoid db for an appropriate reply
|
||||
cursor = self.db.cursor()
|
||||
cursor.execute("""SELECT fact FROM factoids WHERE key = %s""", key)
|
||||
cursor.execute("""SELECT fact FROM factoids WHERE key LIKE %s""", key)
|
||||
if cursor.rowcount == 0:
|
||||
text = self._getDunno(msg.nick)
|
||||
irc.reply(msg, text, prefixName=False)
|
||||
@ -249,7 +249,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||
key, fact = match.groups()
|
||||
cursor = self.db.cursor()
|
||||
# Check and make sure it's not in the DB already
|
||||
cursor.execute("""SELECT * FROM factoids WHERE key = %s""", key)
|
||||
cursor.execute("""SELECT * FROM factoids WHERE key LIKE %s""", key)
|
||||
if cursor.rowcount != 0:
|
||||
irc.error(msg, "Factoid '%s' already exists." % key)
|
||||
return
|
||||
@ -273,7 +273,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||
cursor = self.db.cursor()
|
||||
# Check and make sure it's in the DB
|
||||
cursor.execute("""SELECT locked_at, fact FROM factoids
|
||||
WHERE key = %s""", key)
|
||||
WHERE key LIKE %s""", key)
|
||||
if cursor.rowcount == 0:
|
||||
irc.error(msg, "Factoid '%s' not found." % key)
|
||||
return
|
||||
@ -308,7 +308,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||
cursor = self.db.cursor()
|
||||
# Check and make sure it's in the DB
|
||||
cursor.execute("""SELECT locked_at, fact FROM factoids
|
||||
WHERE key = %s""", key)
|
||||
WHERE key LIKE %s""", key)
|
||||
if cursor.rowcount == 0:
|
||||
irc.error(msg, "Factoid '%s' not found." % key)
|
||||
return
|
||||
@ -338,7 +338,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||
cursor = self.db.cursor()
|
||||
# Check and make sure it's in the DB
|
||||
cursor.execute("""SELECT locked_at, fact FROM factoids
|
||||
WHERE key = %s""", key)
|
||||
WHERE key LIKE %s""", key)
|
||||
if cursor.rowcount == 0:
|
||||
irc.error(msg, "Factoid '%s' not found." % key)
|
||||
return
|
||||
@ -367,7 +367,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||
"""
|
||||
key = privmsgs.getArgs(args, needed=1)
|
||||
cursor = self.db.cursor()
|
||||
cursor.execute("""SELECT fact FROM factoids WHERE key = %s""", key)
|
||||
cursor.execute("""SELECT fact FROM factoids WHERE key LIKE %s""", key)
|
||||
if cursor.rowcount == 0:
|
||||
irc.error(msg, "No such factoid: %s" % key)
|
||||
return
|
||||
@ -388,7 +388,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||
cursor.execute("""SELECT created_by, created_at, modified_by,
|
||||
modified_at, last_requested_by, last_requested_at,
|
||||
requested_count, locked_at FROM
|
||||
factoids WHERE key = %s""", key)
|
||||
factoids WHERE key LIKE %s""", key)
|
||||
if cursor.rowcount == 0:
|
||||
irc.error(msg, "No such factoid: %s" % key)
|
||||
return
|
||||
@ -432,7 +432,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||
key = privmsgs.getArgs(args, needed=1)
|
||||
cursor = self.db.cursor()
|
||||
cursor.execute("""SELECT created_by, locked_at FROM factoids
|
||||
WHERE key = %s""", key)
|
||||
WHERE key LIKE %s""", key)
|
||||
if cursor.rowcount == 0:
|
||||
irc.error(msg, "No such factoid: %s" % key)
|
||||
return
|
||||
@ -559,7 +559,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||
key = privmsgs.getArgs(args, needed=1)
|
||||
cursor = self.db.cursor()
|
||||
cursor.execute("""SELECT key, locked_at FROM factoids
|
||||
WHERE key = %s""", key)
|
||||
WHERE key LIKE %s""", key)
|
||||
if cursor.rowcount == 0:
|
||||
irc.error(msg, "No such factoid: %s" % key)
|
||||
return
|
||||
|
@ -66,6 +66,10 @@ if sqlite is not None:
|
||||
# Test and make sure it's parsing
|
||||
self.assertNotError('moo4 is <reply>(1|2|3)')
|
||||
self.assertRegexp('moo4', '^(1|2|3)$')
|
||||
# Check case-insensitivity
|
||||
self.assertResponse('MOO', 'foo')
|
||||
self.assertResponse('mOo', 'foo')
|
||||
self.assertResponse('MoO', 'foo')
|
||||
|
||||
def testFactinfo(self):
|
||||
self.assertNotError('moo is <reply>foo')
|
||||
@ -206,7 +210,7 @@ if sqlite is not None:
|
||||
|
||||
def testDunnoAdd(self):
|
||||
self.assertNotError('dunnoadd moo')
|
||||
self.assertResponse('asdfagagfosdfk', 'moo (#1)')
|
||||
self.assertResponse('asdfagagfosdfk', 'moo')
|
||||
|
||||
def testDunnoRemove(self):
|
||||
self.assertNotError('dunnoadd moo')
|
||||
|
Loading…
Reference in New Issue
Block a user