mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Made sure the error message is correct when a user tries to removeCapability something that isn't there.
This commit is contained in:
parent
b50a01db7d
commit
3f78522f15
@ -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)
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user