mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Fixed test and the names of some configuration variables.
This commit is contained in:
parent
f3fd7dabe1
commit
2b93f028d9
@ -57,13 +57,13 @@ conf.registerPlugin('Karma')
|
|||||||
conf.registerChannelValue(conf.supybot.plugins.Karma, 'simpleOutput',
|
conf.registerChannelValue(conf.supybot.plugins.Karma, 'simpleOutput',
|
||||||
registry.Boolean(False, """Determines whether the bot will output shorter
|
registry.Boolean(False, """Determines whether the bot will output shorter
|
||||||
versions of the karma output when requesting a single thing's karma."""))
|
versions of the karma output when requesting a single thing's karma."""))
|
||||||
conf.registerChannelValue(conf.supybot.plugins.Karma, 'karmaResponse',
|
conf.registerChannelValue(conf.supybot.plugins.Karma, 'response',
|
||||||
registry.Boolean(False, """Determines whether the bot will reply with a
|
registry.Boolean(False, """Determines whether the bot will reply with a
|
||||||
success message when something's karma is incrneased or decreased."""))
|
success message when something's karma is incrneased or decreased."""))
|
||||||
conf.registerChannelValue(conf.supybot.plugins.Karma, 'karmaRankingDisplay',
|
conf.registerChannelValue(conf.supybot.plugins.Karma, 'rankingDisplay',
|
||||||
registry.Integer(3, """Determines how many highest/lowest karma things are
|
registry.Integer(3, """Determines how many highest/lowest karma things are
|
||||||
shown when karma is called with no arguments."""))
|
shown when karma is called with no arguments."""))
|
||||||
conf.registerChannelValue(conf.supybot.plugins.Karma, 'karmaMostDisplay',
|
conf.registerChannelValue(conf.supybot.plugins.Karma, 'mostDisplay',
|
||||||
registry.Integer(25, """Determines how many karma things are shown when
|
registry.Integer(25, """Determines how many karma things are shown when
|
||||||
the most command is called.'"""))
|
the most command is called.'"""))
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ class Karma(callbacks.PrivmsgCommandAndRegexp, plugins.ChannelDBHandler):
|
|||||||
irc.reply('I didn\'t know the karma for any '
|
irc.reply('I didn\'t know the karma for any '
|
||||||
'of those things.')
|
'of those things.')
|
||||||
else: # No name was given. Return the top/bottom N karmas.
|
else: # No name was given. Return the top/bottom N karmas.
|
||||||
limit = self.registryValue('karmaRankingDisplay', channel)
|
limit = self.registryValue('rankingDisplay', channel)
|
||||||
cursor.execute("""SELECT name, added-subtracted
|
cursor.execute("""SELECT name, added-subtracted
|
||||||
FROM karma
|
FROM karma
|
||||||
ORDER BY added-subtracted DESC
|
ORDER BY added-subtracted DESC
|
||||||
@ -192,7 +192,7 @@ class Karma(callbacks.PrivmsgCommandAndRegexp, plugins.ChannelDBHandler):
|
|||||||
orderby = 'added+subtracted'
|
orderby = 'added+subtracted'
|
||||||
sql = "SELECT name, %s FROM karma ORDER BY %s DESC LIMIT %s" % \
|
sql = "SELECT name, %s FROM karma ORDER BY %s DESC LIMIT %s" % \
|
||||||
(orderby, orderby,
|
(orderby, orderby,
|
||||||
self.registryValue('karmaMostDisplay', channel))
|
self.registryValue('mostDisplay', channel))
|
||||||
db = self.getDb(channel)
|
db = self.getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
@ -215,7 +215,7 @@ class Karma(callbacks.PrivmsgCommandAndRegexp, plugins.ChannelDBHandler):
|
|||||||
cursor.execute("""UPDATE karma
|
cursor.execute("""UPDATE karma
|
||||||
SET added=added+1
|
SET added=added+1
|
||||||
WHERE normalized=%s""", normalized)
|
WHERE normalized=%s""", normalized)
|
||||||
if self.registryValue('karmaResponse', msg.args[0]):
|
if self.registryValue('response', msg.args[0]):
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
|
||||||
def decreaseKarma(self, irc, msg, match):
|
def decreaseKarma(self, irc, msg, match):
|
||||||
@ -229,7 +229,7 @@ class Karma(callbacks.PrivmsgCommandAndRegexp, plugins.ChannelDBHandler):
|
|||||||
cursor.execute("""UPDATE karma
|
cursor.execute("""UPDATE karma
|
||||||
SET subtracted=subtracted+1
|
SET subtracted=subtracted+1
|
||||||
WHERE normalized=%s""", normalized)
|
WHERE normalized=%s""", normalized)
|
||||||
if self.registryValue('karmaResponse', msg.args[0]):
|
if self.registryValue('response', msg.args[0]):
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +69,9 @@ if sqlite is not None:
|
|||||||
'Karma for \'MoO\'.*increased 1.*total.*1')
|
'Karma for \'MoO\'.*increased 1.*total.*1')
|
||||||
|
|
||||||
def testKarmaRankingDisplayConfigurable(self):
|
def testKarmaRankingDisplayConfigurable(self):
|
||||||
self.assertNotError('karma config karma-response on')
|
try:
|
||||||
|
orig = conf.supybot.plugins.Karma.response()
|
||||||
|
conf.supybot.plugins.Karma.response.setValue(True)
|
||||||
self.assertNotError('foo++')
|
self.assertNotError('foo++')
|
||||||
self.assertNotError('foo++')
|
self.assertNotError('foo++')
|
||||||
self.assertNotError('foo++')
|
self.assertNotError('foo++')
|
||||||
@ -91,8 +93,13 @@ if sqlite is not None:
|
|||||||
self.assertNotError('oof--')
|
self.assertNotError('oof--')
|
||||||
self.assertNotError('oof--')
|
self.assertNotError('oof--')
|
||||||
self.assertRegexp('karma', 'foo.*bar.*baz.*oof.*rab.*zab')
|
self.assertRegexp('karma', 'foo.*bar.*baz.*oof.*rab.*zab')
|
||||||
self.assertNotError('karma config karma-ranking-display 4')
|
original = conf.supybot.plugins.Karma.rankingDisplay()
|
||||||
|
conf.supybot.plugins.Karma.rankingDisplay.setValue(4)
|
||||||
self.assertRegexp('karma', 'foo.*bar.*baz.*quux')
|
self.assertRegexp('karma', 'foo.*bar.*baz.*quux')
|
||||||
|
finally:
|
||||||
|
conf.supybot.plugins.Karma.response.setValue(orig)
|
||||||
|
conf.supybot.plugins.Karma.rankingDisplay.setValue(original)
|
||||||
|
|
||||||
|
|
||||||
def testMost(self):
|
def testMost(self):
|
||||||
self.assertError('most increased')
|
self.assertError('most increased')
|
||||||
@ -116,16 +123,24 @@ if sqlite is not None:
|
|||||||
self.assertRegexp('karma most decreased', 'foo.*bar')
|
self.assertRegexp('karma most decreased', 'foo.*bar')
|
||||||
|
|
||||||
def testSimpleOutput(self):
|
def testSimpleOutput(self):
|
||||||
self.assertNotError('karma config simple-output on')
|
try:
|
||||||
|
orig = conf.supybot.plugins.Karma.simpleOutput()
|
||||||
|
conf.supybot.plugins.Karma.simpleOutput.setValue(True)
|
||||||
self.assertNoResponse('foo++', 2)
|
self.assertNoResponse('foo++', 2)
|
||||||
self.assertResponse('karma foo', 'foo: 1')
|
self.assertResponse('karma foo', 'foo: 1')
|
||||||
self.assertNoResponse('bar--', 2)
|
self.assertNoResponse('bar--', 2)
|
||||||
self.assertResponse('karma bar', 'bar: -1')
|
self.assertResponse('karma bar', 'bar: -1')
|
||||||
|
finally:
|
||||||
|
conf.supybot.plugins.Karma.simpleOutput.setValue(orig)
|
||||||
|
|
||||||
def testKarmaOutputConfigurable(self):
|
def testKarmaOutputConfigurable(self):
|
||||||
self.assertNoResponse('foo++', 2)
|
self.assertNoResponse('foo++', 2)
|
||||||
self.assertNotError('karma config karma-response on')
|
try:
|
||||||
|
orig = conf.supybot.plugins.Karma.response()
|
||||||
|
conf.supybot.plugins.Karma.response.setValue(True)
|
||||||
self.assertNotError('foo++')
|
self.assertNotError('foo++')
|
||||||
|
finally:
|
||||||
|
conf.supybot.plugins.Karma.response.setValue(orig)
|
||||||
|
|
||||||
def testKarmaMostDisplayConfigurable(self):
|
def testKarmaMostDisplayConfigurable(self):
|
||||||
self.assertNoResponse('foo++', 1)
|
self.assertNoResponse('foo++', 1)
|
||||||
@ -137,10 +152,15 @@ if sqlite is not None:
|
|||||||
self.assertNoResponse('foo--', 1)
|
self.assertNoResponse('foo--', 1)
|
||||||
self.assertNoResponse('foo--', 1)
|
self.assertNoResponse('foo--', 1)
|
||||||
self.assertNoResponse('foo--', 1)
|
self.assertNoResponse('foo--', 1)
|
||||||
self.assertNotError('karma config karma-most-display 1')
|
try:
|
||||||
|
orig = conf.supybot.plugins.Karma.mostDisplay()
|
||||||
|
conf.supybot.plugins.Karma.mostDisplay.setValue(1)
|
||||||
self.assertRegexp('karma most active', '(?!bar)')
|
self.assertRegexp('karma most active', '(?!bar)')
|
||||||
self.assertNotError('karma config karma-most-display 25')
|
conf.supybot.plugins.Karma.mostDisplay.setValue(25)
|
||||||
self.assertRegexp('karma most active', 'bar')
|
self.assertRegexp('karma most active', 'bar')
|
||||||
|
finally:
|
||||||
|
conf.supybot.plugins.Karma.mostDisplay.setValue(orig)
|
||||||
|
|
||||||
|
|
||||||
def testIncreaseKarmaWithNickNotCallingInvalidCommand(self):
|
def testIncreaseKarmaWithNickNotCallingInvalidCommand(self):
|
||||||
self.assertNoResponse('%s: foo++' % self.irc.nick, 3)
|
self.assertNoResponse('%s: foo++' % self.irc.nick, 3)
|
||||||
|
Loading…
Reference in New Issue
Block a user