2006-06-26 17:57:20 +00:00
|
|
|
from supybot.test import *
|
|
|
|
|
2010-03-30 20:13:51 +00:00
|
|
|
import supybot.conf as conf
|
|
|
|
import supybot.ircmsgs as ircmsgs
|
|
|
|
import supybot.schedule as schedule
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
bConf = conf.supybot.plugins.Bantracker
|
|
|
|
bConf.enabled.setValue(True)
|
|
|
|
|
|
|
|
|
|
|
|
class BantrackerTestCase(ChannelPluginTestCase):
|
2006-06-26 17:57:20 +00:00
|
|
|
plugins = ('Bantracker',)
|
2010-03-30 20:13:51 +00:00
|
|
|
|
|
|
|
def getCallback(self):
|
|
|
|
for cb in self.irc.callbacks:
|
|
|
|
if cb.name() == 'Bantracker':
|
|
|
|
break
|
|
|
|
return cb
|
|
|
|
|
|
|
|
def testCommentRequest(self):
|
|
|
|
ban = ircmsgs.ban('#test', 'asd!*@*', prefix='op!user@host.net')
|
|
|
|
self.irc.feedMsg(ban)
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
# ban id is None is because there's no database for this TestCase
|
|
|
|
self.assertEqual(str(msg).strip(),
|
|
|
|
"PRIVMSG op :Please comment on the ban of asd!*@* in #test, use: @comment None"
|
|
|
|
" <comment>")
|
|
|
|
|
|
|
|
def testReviewResquest(self):
|
|
|
|
cb = self.getCallback()
|
|
|
|
ban = ircmsgs.ban('#test', 'asd!*@*', prefix='op!user@host.net')
|
|
|
|
self.irc.feedMsg(ban)
|
|
|
|
self.irc.takeMsg() # ignore comment request comment
|
|
|
|
bConf.reviewAfterTime.setValue(1)
|
|
|
|
cb.reviewBans()
|
|
|
|
self.assertFalse(cb.pendingReviews)
|
|
|
|
print 'waiting 2 secs..'
|
|
|
|
time.sleep(2)
|
|
|
|
cb.reviewBans()
|
|
|
|
# check is pending
|
|
|
|
self.assertTrue(cb.pendingReviews)
|
|
|
|
# check msg if op and only op says something
|
|
|
|
self.feedMsg('Hi!', to='#test', frm='dude!user@host.net')
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(msg, None)
|
|
|
|
self.feedMsg('Hi!', to='#test', frm='op!user@host.net')
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(str(msg).strip(),
|
|
|
|
"PRIVMSG op :Please review ban 'asd!*@*' in #test")
|
|
|
|
# don't ask again
|
|
|
|
cb.reviewBans()
|
|
|
|
self.assertFalse(cb.pendingReviews)
|
|
|
|
|
|
|
|
|