From 48737f2085813ec2349e1da003cc2ae8905a28d7 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 21 Oct 2003 05:19:54 +0000 Subject: [PATCH] Made command names more generic. --- plugins/Factoids.py | 6 +++--- plugins/Quotes.py | 10 +++++----- test/test_Factoids.py | 30 +++++++++++++++--------------- test/test_Quotes.py | 41 +++++++++++++++++++++-------------------- 4 files changed, 44 insertions(+), 43 deletions(-) diff --git a/plugins/Factoids.py b/plugins/Factoids.py index 1abe0429b..a374388fd 100644 --- a/plugins/Factoids.py +++ b/plugins/Factoids.py @@ -296,7 +296,7 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg): else: irc.error(msg, conf.replyNoCapability % capability) - def randomfactoid(self, irc, msg, args): + def random(self, irc, msg, args): """[] Returns a random factoid from the database for . @@ -318,7 +318,7 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg): else: irc.error(msg, 'I couldn\'t find a factoid.') - def factoidinfo(self, irc, msg, args): + def info(self, irc, msg, args): """[] Gives information about the factoid(s) associated with . @@ -351,7 +351,7 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg): irc.reply(msg, s) _sqlTrans = string.maketrans('*?', '%_') - def searchfactoids(self, irc, msg, args): + def search(self, irc, msg, args): """[] [--{regexp,exact}=] [] Searches the keyspace for keys matching . If --regexp is given, diff --git a/plugins/Quotes.py b/plugins/Quotes.py index 0acc6e862..992a7af95 100644 --- a/plugins/Quotes.py +++ b/plugins/Quotes.py @@ -75,7 +75,7 @@ class Quotes(plugins.ChannelDBHandler, callbacks.Privmsg): db.commit() return db - def addquote(self, irc, msg, args): + def add(self, irc, msg, args): """[] Adds to the quotes database for . is only @@ -98,7 +98,7 @@ class Quotes(plugins.ChannelDBHandler, callbacks.Privmsg): quoteid = cursor.fetchone()[0] irc.reply(msg, '%s (Quote #%s added)' % (conf.replySuccess, quoteid)) - def numquotes(self, irc, msg, args): + def num(self, irc, msg, args): """[] Returns the numbers of quotes in the quote database for . @@ -191,7 +191,7 @@ class Quotes(plugins.ChannelDBHandler, callbacks.Privmsg): irc.reply(msg, utils.commaAndify(idsWithSnippets)) ### FIXME: we need to remove those predicates from the database. - def randomquote(self, irc, msg, args): + def random(self, irc, msg, args): """[] Returns a random quote from . is only necessary if @@ -209,7 +209,7 @@ class Quotes(plugins.ChannelDBHandler, callbacks.Privmsg): (id,) = cursor.fetchone() self.quote(irc, msg, [channel, '--id', str(id)]) - def quoteinfo(self, irc, msg, args): + def info(self, irc, msg, args): """[] Returns the metadata about the quote in the quotes @@ -230,7 +230,7 @@ class Quotes(plugins.ChannelDBHandler, callbacks.Privmsg): else: irc.error(msg, 'There isn\'t a quote with that id.') - def removequote(self, irc, msg, args): + def remove(self, irc, msg, args): """[] Removes quote from the quotes database for . diff --git a/test/test_Factoids.py b/test/test_Factoids.py index 99bae02a8..3ead12023 100644 --- a/test/test_Factoids.py +++ b/test/test_Factoids.py @@ -40,13 +40,13 @@ if sqlite is not None: class FactoidsTestCase(ChannelPluginTestCase, PluginDocumentation): plugins = ('Factoids',) def testRandomfactoid(self): - self.assertError('randomfactoid') + self.assertError('random') self.assertNotError('learn jemfinch as my primary author') - self.assertRegexp('randomfactoid', 'primary author') + self.assertRegexp('random', 'primary author') def testLearn(self): self.assertNotError('learn jemfinch as my primary author') - self.assertNotError('factoidinfo jemfinch') + self.assertNotError('info jemfinch') self.assertRegexp('whatis jemfinch', 'my primary author') self.assertRegexp('whatis JEMFINCH', 'my primary author') self.assertRegexp('whatis JEMFINCH 1', 'my primary author') @@ -60,10 +60,10 @@ if sqlite is not None: self.assertNotError('forget jemfinch 2') self.assertNotError('forget jemfinch 1') self.assertError('whatis jemfinch') - self.assertError('factoidinfo jemfinch') + self.assertError('info jemfinch') self.assertNotError('learn foo bar as baz') - self.assertNotError('factoidinfo foo bar') + self.assertNotError('info foo bar') self.assertRegexp('whatis foo bar', 'baz') self.assertNotError('learn foo bar as quux') self.assertRegexp('whatis foo bar', '.*baz.*quux') @@ -71,7 +71,7 @@ if sqlite is not None: self.assertNotError('forget foo bar 2') self.assertNotError('forget foo bar 1') self.assertError('whatis foo bar') - self.assertError('factoidinfo foo bar') + self.assertError('info foo bar') self.assertRegexp('learn foo bar baz', '^learn') # No 'as' self.assertRegexp('learn foo bar', '^learn') # No 'as' @@ -82,25 +82,25 @@ if sqlite is not None: self.assertNotError('learn inkedmn as another of my developers') self.assertNotError('learn jamessan as a developer of much python') self.assertNotError('learn bwp as author of my weather command') - self.assertRegexp('searchfactoids --regexp /.w./', 'bwp') - self.assertRegexp('searchfactoids --regexp /^.+i/', + self.assertRegexp('search --regexp /.w./', 'bwp') + self.assertRegexp('search --regexp /^.+i/', 'jemfinch.*strike') - self.assertNotRegexp('searchfactoids --regexp /^.+i/', 'inkedmn') - self.assertRegexp('searchfactoids --regexp /^j/', + self.assertNotRegexp('search --regexp /^.+i/', 'inkedmn') + self.assertRegexp('search --regexp /^j/', 'jemfinch.*jamessan') - self.assertRegexp('searchfactoids j*', 'jemfinch.*jamessan') - self.assertRegexp('searchfactoids --exact ke', + self.assertRegexp('search j*', 'jemfinch.*jamessan') + self.assertRegexp('search --exact ke', 'inkedmn.*strike|strike.*inkedmn') - self.assertRegexp('searchfactoids *ke*', + self.assertRegexp('search *ke*', 'inkedmn.*strike|strike.*inkedmn') def testNotZeroIndexed(self): self.assertNotError('learn foo as bar') - self.assertNotRegexp('factoidinfo foo', '#0') + self.assertNotRegexp('info foo', '#0') self.assertNotRegexp('whatis foo', '#0') self.assertNotError('learn foo as baz') - self.assertNotRegexp('factoidinfo foo', '#0') + self.assertNotRegexp('info foo', '#0') self.assertNotRegexp('whatis foo', '#0') diff --git a/test/test_Quotes.py b/test/test_Quotes.py index 8531ac4b1..820b1933c 100644 --- a/test/test_Quotes.py +++ b/test/test_Quotes.py @@ -40,35 +40,36 @@ if sqlite is not None: class QuotesTestCase(PluginTestCase, PluginDocumentation): plugins = ('Quotes',) def test(self): - self.assertRegexp('numquotes #foo', '0') - self.assertRegexp('addquote #foo foo', 'Quote #1 added') - self.assertRegexp('numquotes #foo', '1') + self.assertRegexp('num #foo', '0') + self.assertRegexp('add #foo foo', 'Quote #1 added') + self.assertRegexp('num #foo', '1') self.assertResponse('quote #foo --id 1', '#1: foo') self.assertResponse('quote #foo 1', '#1: foo') - self.assertRegexp('addquote #foo bar','Quote #2 added') + self.assertRegexp('add #foo bar','Quote #2 added') self.assertResponse('quote #foo 2', '#2: bar') self.assertResponse('quote #foo --id 2', '#2: bar') - self.assertRegexp('addquote #foo baz','Quote #3 added') - self.assertRegexp('numquotes #foo', '3') + self.assertRegexp('add #foo baz','Quote #3 added') + self.assertRegexp('num #foo', '3') self.assertResponse('quote #foo 3', '#3: baz') self.assertRegexp('quote #foo --regexp m/ba/', 'bar.*baz') self.assertRegexp('quote #foo --regexp ba', 'bar.*baz') self.assertRegexp('quote #foo --with bar', '#2: bar') self.assertRegexp('quote #foo bar', '#2: bar') - self.assertNotError('quoteinfo #foo 1') - self.assertNotError('randomquote #foo') - self.assertError('removequote #foo 4') - self.assertError('quoteinfo #foo 4') - self.assertNotError('removequote #foo 3') - self.assertRegexp('numquotes #foo', '2') - self.assertNotError('removequote #foo 1') - self.assertError('quoteinfo #foo 3') - self.assertError('quoteinfo #foo 1') - self.assertRegexp('randomquote #foo', '#2') - self.assertError('removequote #foo 3') - self.assertNotError('removequote #foo 2') - self.assertRegexp('numquotes #foo', '0') - self.assertError('randomquote #foo') + self.assertNotError('info #foo 1') + self.assertNotError('random #foo') + self.assertError('remove #foo 4') + self.assertError('info #foo 4') + self.assertNotError('quote #foo 3') + self.assertNotError('remove #foo 3') + self.assertRegexp('num #foo', '2') + self.assertNotError('remove #foo 1') + self.assertError('info #foo 3') + self.assertError('info #foo 1') + self.assertRegexp('random #foo', '#2') + self.assertError('remove #foo 3') + self.assertNotError('remove #foo 2') + self.assertRegexp('num #foo', '0') + self.assertError('random #foo')