Slightly tweaked, added test.

This commit is contained in:
Jeremy Fincher 2003-12-03 01:55:19 +00:00
parent fe9468c0e6
commit d4442a04ff
2 changed files with 16 additions and 1 deletions

View File

@ -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*')

View File

@ -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')