mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 02:24:12 +01:00
Slightly tweaked, added test.
This commit is contained in:
parent
fe9468c0e6
commit
d4442a04ff
@ -510,8 +510,10 @@ class Fun(callbacks.Privmsg):
|
||||
"""
|
||||
nick = msg.nick
|
||||
channel = msg.args[0]
|
||||
if not ircutils.isChannel(channel):
|
||||
irc.error(msg, 'This message must be sent in a channel.')
|
||||
if random.randint(1, 6) == 1:
|
||||
irc.queueMsg(ircmsgs.kick(channel, nick))
|
||||
irc.queueMsg(ircmsgs.kick(channel, nick, 'BANG!'))
|
||||
else:
|
||||
irc.reply(msg, '*click*')
|
||||
|
||||
|
@ -37,6 +37,19 @@ import utils
|
||||
|
||||
class FunTest(ChannelPluginTestCase, PluginDocumentation):
|
||||
plugins = ('Fun',)
|
||||
def testRoulette(self):
|
||||
sawKick = False
|
||||
for i in xrange(100):
|
||||
m = self.getMsg('roulette')
|
||||
if m.command == 'PRIVMSG':
|
||||
self.failUnless('click' in m.args[1].lower())
|
||||
elif m.command == 'KICK':
|
||||
sawKick = True
|
||||
self.failUnless('bang' in m.args[2].lower())
|
||||
else:
|
||||
self.fail('Got something other than a kick or a privmsg.')
|
||||
self.failUnless(sawKick, 'Didn\'t get a kick in %s iterations!' % i)
|
||||
|
||||
def testNoErrors(self):
|
||||
self.assertNotError('leet foobar')
|
||||
self.assertNotError('lithp meghan sweeney')
|
||||
|
Loading…
Reference in New Issue
Block a user