Made Owner complain if there is more than one src/ plugin with a given command.

This commit is contained in:
Jeremy Fincher 2003-11-09 14:01:36 +00:00
parent 4b94ebe146
commit 8580b6a44e
2 changed files with 18 additions and 16 deletions

View File

@ -97,10 +97,9 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
cbs = callbacks.findCallbackForCommand(irc, command) cbs = callbacks.findCallbackForCommand(irc, command)
if len(cbs) > 1: if len(cbs) > 1:
names = [cb.name() for cb in cbs] names = [cb.name() for cb in cbs]
for name in names: srcs = [name for name in names if name in self._srcPlugins]
if name in self._srcPlugins: if len(srcs) == 1:
tokens.insert(0, name) tokens.insert(0, srcs[0])
break
else: else:
ambiguousCommands[command] = names ambiguousCommands[command] = names
for elt in tokens: for elt in tokens:

View File

@ -35,7 +35,7 @@ import conf
import Owner import Owner
class OwnerTestCase(PluginTestCase, PluginDocumentation): class OwnerTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Utilities', 'Relay', 'Network') plugins = ('Utilities', 'Relay', 'Network', 'Admin', 'Channel')
def testDefaultPlugin(self): def testDefaultPlugin(self):
self.assertError('whois osu.edu') self.assertError('whois osu.edu')
self.assertNotError('defaultplugin whois network') self.assertNotError('defaultplugin whois network')
@ -57,6 +57,9 @@ class OwnerTestCase(PluginTestCase, PluginDocumentation):
finally: finally:
conf.allowEval = originalConfAllowEval conf.allowEval = originalConfAllowEval
def testSrcAmbiguity(self):
self.assertError('addcapability foo bar')
def testExec(self): def testExec(self):
try: try:
originalConfAllowEval = conf.allowEval originalConfAllowEval = conf.allowEval
@ -92,22 +95,22 @@ class OwnerTestCase(PluginTestCase, PluginDocumentation):
def testLoad(self): def testLoad(self):
self.assertError('load Owner') self.assertError('load Owner')
self.assertError('load owner') self.assertError('load owner')
self.assertNotError('load Admin') self.assertNotError('load Alias')
self.assertNotError('list Owner') self.assertNotError('list Owner')
def testReload(self): def testReload(self):
self.assertError('reload Admin') self.assertError('reload Alias')
self.assertNotError('load Admin') self.assertNotError('load Alias')
self.assertNotError('reload Admin') self.assertNotError('reload ALIAS')
self.assertNotError('reload ADMIN') self.assertNotError('reload ALIAS')
def testUnload(self): def testUnload(self):
self.assertError('unload Admin') self.assertError('unload Foobar')
self.assertNotError('load Admin') self.assertNotError('load Alias')
self.assertNotError('unload Admin') self.assertNotError('unload Alias')
self.assertError('unload Admin') self.assertError('unload Alias')
self.assertNotError('load ADMIN') self.assertNotError('load ALIAS')
self.assertNotError('unload ADMIN') self.assertNotError('unload ALIAS')
def testSetconf(self): def testSetconf(self):
self.assertRegexp('setconf', 'confDir') self.assertRegexp('setconf', 'confDir')