mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-25 18:10:44 +01:00
make 'factoids info' include usage count in output. add test for same.
This commit is contained in:
parent
32c718ca66
commit
97149b403a
@ -424,18 +424,19 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
irc.error('No factoid matches that key.')
|
irc.error('No factoid matches that key.')
|
||||||
return
|
return
|
||||||
(id, locked) = map(int, results[0])
|
(id, locked) = map(int, results[0])
|
||||||
cursor.execute("""SELECT added_by, added_at FROM factoids
|
cursor.execute("""SELECT added_by, added_at, usage_count FROM factoids
|
||||||
WHERE key_id=?
|
WHERE key_id=?
|
||||||
ORDER BY id""", (id,))
|
ORDER BY id""", (id,))
|
||||||
factoids = cursor.fetchall()
|
factoids = cursor.fetchall()
|
||||||
L = []
|
L = []
|
||||||
counter = 0
|
counter = 0
|
||||||
for (added_by, added_at) in factoids:
|
for (added_by, added_at, usage_count) in factoids:
|
||||||
counter += 1
|
counter += 1
|
||||||
added_at = time.strftime(conf.supybot.reply.format.time(),
|
added_at = time.strftime(conf.supybot.reply.format.time(),
|
||||||
time.localtime(int(added_at)))
|
time.localtime(int(added_at)))
|
||||||
L.append(format('#%i was added by %s at %s',
|
L.append(format('#%i was added by %s at %s, and has been recalled '
|
||||||
counter, added_by, added_at))
|
'%n',
|
||||||
|
counter, added_by, added_at, (usage_count, 'time')))
|
||||||
factoids = '; '.join(L)
|
factoids = '; '.join(L)
|
||||||
s = format('Key %q is %s and has %n associated with it: %s',
|
s = format('Key %q is %s and has %n associated with it: %s',
|
||||||
key, locked and 'locked' or 'not locked',
|
key, locked and 'locked' or 'not locked',
|
||||||
|
@ -125,6 +125,12 @@ class FactoidsTestCase(ChannelPluginTestCase):
|
|||||||
self.assertNotError('learn foo as bar')
|
self.assertNotError('learn foo as bar')
|
||||||
self.assertNotRegexp('info foo', '2 factoids')
|
self.assertNotRegexp('info foo', '2 factoids')
|
||||||
|
|
||||||
|
def testInfoUsageCount(self):
|
||||||
|
self.assertNotError('learn moo as cow')
|
||||||
|
self.assertRegexp('info moo', 'recalled 0 times')
|
||||||
|
self.assertNotError('whatis moo')
|
||||||
|
self.assertRegexp('info moo', 'recalled 1 time')
|
||||||
|
|
||||||
def testLearnSeparator(self):
|
def testLearnSeparator(self):
|
||||||
self.assertError('learn foo is bar')
|
self.assertError('learn foo is bar')
|
||||||
self.assertNotError('learn foo as bar')
|
self.assertNotError('learn foo as bar')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user