Admin refactored ignore/unignore/ignores to ignore add/remove/list, and changed tests accordingly.

This commit is contained in:
Ali Afshar 2005-03-25 14:03:44 +00:00
parent 890d92df0e
commit 4e7a00d504
2 changed files with 46 additions and 44 deletions

View File

@ -291,7 +291,9 @@ class Admin(callbacks.Plugin):
irc.error(s)
remove = wrap(remove, ['otherUser','lowered'])
def ignore(self, irc, msg, args, hostmask, expires):
class ignore(callbacks.Commands):
def add(self, irc, msg, args, hostmask, expires):
"""<hostmask|nick> [<expires>]
Ignores <hostmask> or, if a nick is given, ignores whatever hostmask
@ -303,9 +305,9 @@ class Admin(callbacks.Plugin):
"""
ircdb.ignores.add(hostmask, expires)
irc.replySuccess()
ignore = wrap(ignore, ['hostmask', additional('expiry', 0)])
add = wrap(add, ['hostmask', additional('expiry', 0)])
def unignore(self, irc, msg, args, hostmask):
def remove(self, irc, msg, args, hostmask):
"""<hostmask|nick>
Ignores <hostmask> or, if a nick is given, ignores whatever hostmask
@ -316,9 +318,9 @@ class Admin(callbacks.Plugin):
irc.replySuccess()
except KeyError:
irc.error('%s wasn\'t in the ignores database.' % hostmask)
unignore = wrap(unignore, ['hostmask'])
remove = wrap(remove, ['hostmask'])
def ignores(self, irc, msg, args):
def list(self, irc, msg, args):
"""takes no arguments
Returns the hostmasks currently being globally ignored.
@ -328,7 +330,7 @@ class Admin(callbacks.Plugin):
irc.reply(format('%L', (map(repr,ircdb.ignores.hostmasks))))
else:
irc.reply('I\'m not currently globally ignoring anyone.')
ignores = wrap(ignores)
list = wrap(list)
Class = Admin

View File

@ -48,18 +48,18 @@ class AdminTestCase(PluginTestCase):
getAfterJoinMessages()
self.assertRegexp('channels', '#bar, #Baz, and #foo')
def testIgnoreUnignore(self):
self.assertNotError('admin ignore foo!bar@baz')
self.assertError('admin ignore alsdkfjlasd')
self.assertNotError('admin unignore foo!bar@baz')
self.assertError('admin unignore foo!bar@baz')
def testIgnoreAddRemove(self):
self.assertNotError('admin ignore add foo!bar@baz')
self.assertError('admin ignore add alsdkfjlasd')
self.assertNotError('admin ignore remove foo!bar@baz')
self.assertError('admin ignore remove foo!bar@baz')
def testIgnores(self):
self.assertNotError('admin ignores')
self.assertNotError('admin ignore foo!bar@baz')
self.assertNotError('admin ignores')
self.assertNotError('admin ignore foo!bar@baz')
self.assertNotError('admin ignores')
def testIgnoreList(self):
self.assertNotError('admin ignore list')
self.assertNotError('admin ignore add foo!bar@baz')
self.assertNotError('admin ignore list')
self.assertNotError('admin ignore add foo!bar@baz')
self.assertRegexp('admin ignore list', 'foo')
def testCapabilityAdd(self):
self.assertError('capability add foo bar')