From fa589ac423a16e8a429737eb8a39813ebd1afa9f Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Fri, 24 Oct 2003 09:10:10 +0000 Subject: [PATCH] Fix for bug #829353; added a test for the remove command. --- plugins/Alias.py | 4 ++-- test/test_Alias.py | 36 +++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/plugins/Alias.py b/plugins/Alias.py index 6754ead4f..197b40a79 100644 --- a/plugins/Alias.py +++ b/plugins/Alias.py @@ -223,7 +223,7 @@ class Alias(callbacks.Privmsg): else: raise AliasError, 'There is no such alias.' - def alias(self, irc, msg, args): + def add(self, irc, msg, args): """ Defines an alias for the commands . The @@ -238,7 +238,7 @@ class Alias(callbacks.Privmsg): except AliasError, e: irc.error(msg, str(e)) - def unalias(self, irc, msg, args): + def remove(self, irc, msg, args): """ Removes the given alias, if unfrozen. diff --git a/test/test_Alias.py b/test/test_Alias.py index 997907ca1..66228d170 100644 --- a/test/test_Alias.py +++ b/test/test_Alias.py @@ -68,48 +68,54 @@ class FunctionsTest(unittest.TestCase): class AliasTestCase(ChannelPluginTestCase, PluginDocumentation): plugins = ('Alias', 'Fun', 'Utilities', 'Misc') def testAliasHelp(self): - self.assertNotError('alias slashdot foo') + self.assertNotError('alias add slashdot foo') self.assertRegexp('help slashdot', "Alias for 'foo'") + + def testRemove(self): + self.assertNotError('alias add foo echo bar') + self.assertResponse('foo', 'bar') + self.assertNotError('alias remove foo') + self.assertNoResponse('foo', 2) def testDollars(self): - self.assertNotError('alias rot26 "rot13 [rot13 $1]"') + self.assertNotError('alias add rot26 "rot13 [rot13 $1]"') self.assertResponse('rot26 foobar', 'foobar') def testMoreDollars(self): - self.assertNotError('alias rev "echo $3 $2 $1"') + self.assertNotError('alias add rev "echo $3 $2 $1"') self.assertResponse('rev foo bar baz', 'baz bar foo') def testAllArgs(self): - self.assertNotError('alias swap "echo $2 $1 $*"') + self.assertNotError('alias add swap "echo $2 $1 $*"') self.assertResponse('swap 1 2 3 4 5', '2 1 3 4 5') - self.assertError('alias foo "echo $1 @1 $*"') + self.assertError('alias add foo "echo $1 @1 $*"') def testNoRecursion(self): - self.assertError('alias rotinfinity "rot13 [rotinfinity $1]"') + self.assertError('alias add rotinfinity "rot13 [rotinfinity $1]"') def testNonCanonicalName(self): - self.assertError('alias FOO foo') - self.assertError('alias [] foo') - self.assertError('alias "foo bar" foo') + self.assertError('alias add FOO foo') + self.assertError('alias add [] foo') + self.assertError('alias add "foo bar" foo') try: conf.enablePipeSyntax = True - self.assertError('alias "foo|bar" foo') + self.assertError('alias add "foo|bar" foo') conf.enablePipeSyntax = False - self.assertNotError('alias "foo|bar" foo') + self.assertNotError('alias add "foo|bar" foo') finally: conf.enablePipeSyntax = False def testNotCannotNestRaised(self): - self.assertNotError('alias mytell "tell $channel $1"') + self.assertNotError('alias add mytell "tell $channel $1"') self.assertNotError('mytell #foo bugs') self.assertNoResponse('blah blah blah', 2) def testChannel(self): - self.assertNotError('alias channel echo $channel') + self.assertNotError('alias add channel echo $channel') self.assertResponse('channel', self.channel) def testNick(self): - self.assertNotError('alias sendingnick "rot13 [rot13 $nick]"') + self.assertNotError('alias add sendingnick "rot13 [rot13 $nick]"') self.assertResponse('sendingnick', self.nick) def testAddRemoveAlias(self): @@ -122,7 +128,7 @@ class AliasTestCase(ChannelPluginTestCase, PluginDocumentation): self.assertNoResponse('foobar', 2) def testOptionalArgs(self): - self.assertNotError('alias myrepr "repr @1"') + self.assertNotError('alias add myrepr "repr @1"') self.assertResponse('myrepr foo', '"foo"') self.assertResponse('myrepr ""', '""')