mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 21:29:24 +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.')
|
||||
return
|
||||
(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=?
|
||||
ORDER BY id""", (id,))
|
||||
factoids = cursor.fetchall()
|
||||
L = []
|
||||
counter = 0
|
||||
for (added_by, added_at) in factoids:
|
||||
for (added_by, added_at, usage_count) in factoids:
|
||||
counter += 1
|
||||
added_at = time.strftime(conf.supybot.reply.format.time(),
|
||||
time.localtime(int(added_at)))
|
||||
L.append(format('#%i was added by %s at %s',
|
||||
counter, added_by, added_at))
|
||||
L.append(format('#%i was added by %s at %s, and has been recalled '
|
||||
'%n',
|
||||
counter, added_by, added_at, (usage_count, 'time')))
|
||||
factoids = '; '.join(L)
|
||||
s = format('Key %q is %s and has %n associated with it: %s',
|
||||
key, locked and 'locked' or 'not locked',
|
||||
|
@ -125,6 +125,12 @@ class FactoidsTestCase(ChannelPluginTestCase):
|
||||
self.assertNotError('learn foo as bar')
|
||||
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):
|
||||
self.assertError('learn foo is bar')
|
||||
self.assertNotError('learn foo as bar')
|
||||
|
Loading…
Reference in New Issue
Block a user