mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
make 'factoids info' include usage count in output. add test for same.
This commit is contained in:
parent
e71ee8fbb1
commit
471921eab6
@ -433,18 +433,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 '
|
||||||
counter, added_by, added_at))
|
'recalled %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…
Reference in New Issue
Block a user