Made sure the error message is correct when a user tries to removeCapability something that isn't there.

This commit is contained in:
Jeremy Fincher 2003-09-23 17:05:53 +00:00
parent b50a01db7d
commit 3f78522f15
2 changed files with 11 additions and 1 deletions

View File

@ -159,11 +159,16 @@ class AdminCommands(privmsgs.CapabilityCheckingPrivmsg):
try:
id = ircdb.users.getUserId(name)
user = ircdb.users.getUser(id)
except KeyError:
irc.error(msg, conf.replyNoUser)
return
try:
user.removeCapability(capability)
ircdb.users.setUser(id, user)
irc.reply(msg, conf.replySuccess)
except KeyError:
irc.error(msg, conf.replyNoUser)
irc.error(msg, 'That user doesn\'t have that capability.')
return
else:
s = 'You can\'t remove capabilities you don\'t have.'
irc.error(msg, s)

View File

@ -39,6 +39,11 @@ class AdminCommandsTestCase(PluginTestCase, PluginDocumentation):
def testAddcapability(self):
self.assertError('addcapability sdlkfj foo')
(id, u) = ircdb.users.newUser()
u.name = 'foo'
ircdb.users.setUser(id, u)
self.assertError('removecapability foo bar')
self.assertNotRegexp('removecapability foo bar', 'find')
def testRemoveCapability(self):
self.assertError('removecapability alsdfkjasd foo')