diff --git a/test/test.py b/test/test.py index 58f8a092f..8e47c8071 100755 --- a/test/test.py +++ b/test/test.py @@ -30,6 +30,7 @@ ### import supybot +import logging import conf conf.dataDir = 'test-data' @@ -37,6 +38,7 @@ conf.confDir = 'test-conf' conf.logDir = 'test-log' conf.replyWhenNotCommand = False conf.stdoutLogging = False +conf.minimumLogPriority = logging.DEBUG conf.detailedTracebacks = False # Bugs in cgitb can be bad. import fix @@ -57,6 +59,7 @@ class path(str): return self._r.split(self) == self._r.split(other) if __name__ == '__main__': + import testsupport import optparse if not os.path.exists(conf.dataDir): @@ -68,11 +71,6 @@ if __name__ == '__main__': if not os.path.exists(conf.logDir): os.mkdir(conf.logDir) -## for filename in os.listdir(conf.logDir): -## if filename == 'plugins': -## continue -## filename = os.path.join(conf.logDir, filename) -## os.remove(filename) pluginLogDir = os.path.join(conf.logDir, 'plugins') for filename in os.listdir(pluginLogDir): os.remove(os.path.join(pluginLogDir, filename)) @@ -92,9 +90,17 @@ if __name__ == '__main__': parser.add_option('-v', '--verbose', action='store_true', default=False, help='Sets the verbose flag, printing extra information ' 'about each test that runs.') + parser.add_option('', '--nonetwork', action='store_true', default=False, + help='Causes the network-based tests not to run.') + parser.add_option('', '--noplugins', action='store_true', default=False, + help='Causes the plugin tests not to run.') (options, args) = parser.parse_args() if not args: - args = map(path, glob.glob(os.path.join('test', 'test_*.py'))) + if options.noplugins: + pattern = 'test_[a-z]*.py' + else: + pattern = 'test_*.py' + args = map(path, glob.glob(os.path.join('test', pattern))) if options.exclusions: for name in map(path, options.exclusions): @@ -113,6 +119,9 @@ if __name__ == '__main__': else: world.myVerbose = False + if options.nonetwork: + testsupport.network = False + world.testing = True names = [os.path.splitext(os.path.basename(name))[0] for name in args] names.sort() diff --git a/test/test_Amazon.py b/test/test_Amazon.py index b85330fee..101510803 100644 --- a/test/test_Amazon.py +++ b/test/test_Amazon.py @@ -33,7 +33,7 @@ from testsupport import * LICENSE_KEY = 'INITIAL_NON_LICENSE_KEY' -if LICENSE_KEY != 'INITIAL_NON_LICENSE_KEY': +if LICENSE_KEY != 'INITIAL_NON_LICENSE_KEY' and network: class AmazonTestCase(PluginTestCase, PluginDocumentation): plugins = ('Amazon',) def setUp(self): diff --git a/test/test_Babelfish.py b/test/test_Babelfish.py index 3fd702d2d..ca68d02f6 100644 --- a/test/test_Babelfish.py +++ b/test/test_Babelfish.py @@ -31,20 +31,21 @@ from testsupport import * -class BabelFishTestCase(PluginTestCase, PluginDocumentation): - plugins = ('Babelfish',) - def testTranslate(self): - self.assertResponse('translate en sp food', - 'alimento') - self.assertError('translate foo en food') - self.assertError('translate en foo food') +if network: + class BabelFishTestCase(PluginTestCase, PluginDocumentation): + plugins = ('Babelfish',) + def testTranslate(self): + self.assertResponse('translate en sp food', + 'alimento') + self.assertError('translate foo en food') + self.assertError('translate en foo food') - def testBabelize(self): - self.assertNotError('babelize en sp foo') - self.assertError('babelize sp fr foo') + def testBabelize(self): + self.assertNotError('babelize en sp foo') + self.assertError('babelize sp fr foo') - def testRandomlanguage(self): - self.assertNotError('randomlanguage') + def testRandomlanguage(self): + self.assertNotError('randomlanguage') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_Bugzilla.py b/test/test_Bugzilla.py index e2eb8041d..6565e3bd5 100644 --- a/test/test_Bugzilla.py +++ b/test/test_Bugzilla.py @@ -31,26 +31,27 @@ from testsupport import * -class BugzillaTest(PluginTestCase, PluginDocumentation): - plugins = ('Bugzilla',) - def testBug(self): - self.assertNotError('bug gcc 5') +if network: + class BugzillaTest(PluginTestCase, PluginDocumentation): + plugins = ('Bugzilla',) + def testBug(self): + self.assertNotError('bug gcc 5') - def testAddRemove(self): - self.assertNotError('add xiph http://bugs.xiph.org/ Xiph') - self.assertNotError('bug xiph 413') - self.assertNotError('remove xiph') - self.assertError('bug xiph 413') + def testAddRemove(self): + self.assertNotError('add xiph http://bugs.xiph.org/ Xiph') + self.assertNotError('bug xiph 413') + self.assertNotError('remove xiph') + self.assertError('bug xiph 413') - def testSearch(self): - self.assertNotError('search gcc alpha') - self.assertNotError('search --keywords=fixed gcc alpha') + def testSearch(self): + self.assertNotError('search gcc alpha') + self.assertNotError('search --keywords=fixed gcc alpha') - def testConfigBugzillaSnarfer(self): - self.assertNotError('bugzilla config bug-snarfer off') - self.assertNoResponse('http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5') - self.assertNotError('bugzilla config bug-snarfer on') - self.assertNotError('http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5') + def testConfigBugzillaSnarfer(self): + self.assertNotError('bugzilla config bug-snarfer off') + self.assertNoResponse('http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5') + self.assertNotError('bugzilla config bug-snarfer on') + self.assertNotError('http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_Channel.py b/test/test_Channel.py index 66b89bb0d..ec306a812 100644 --- a/test/test_Channel.py +++ b/test/test_Channel.py @@ -87,17 +87,32 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation): self.irc.feedMsg(ircmsgs.op(self.channel, self.nick)) self.assertNotError('voice') - def testKban(self): - self.irc.feedMsg(ircmsgs.join(self.channel, prefix='foobar!user@host')) - self.assertError('kban foobar') - self.irc.feedMsg(ircmsgs.op(self.channel, self.nick)) - m = self.getMsg('kban foobar') - self.assertEqual(m, ircmsgs.ban(self.channel, '*!*@host')) + def assertBan(self, query, hostmask, **kwargs): + m = self.getMsg(query, **kwargs) + self.assertEqual(m, ircmsgs.ban(self.channel, hostmask)) m = self.getMsg(' ') - self.assertEqual(m, ircmsgs.kick(self.channel, 'foobar', self.nick)) + self.assertEqual(m.command, 'KICK') + + def testKban(self): + self.irc.prefix = 'something!else@somehwere.else' + self.irc.nick = 'something' + self.irc.feedMsg(ircmsgs.join(self.channel, + prefix='foobar!user@host.domain.tld')) + self.assertError('kban foobar') + self.irc.feedMsg(ircmsgs.op(self.channel, self.irc.nick)) + self.assertBan('kban foobar', '*!*@*.domain.tld') + self.assertBan('kban --exact foobar', 'foobar!user@host.domain.tld') + self.assertBan('kban --host foobar', '*!*@host.domain.tld') + self.assertBan('kban --user foobar', '*!user@*') + self.assertBan('kban --nick foobar', 'foobar!*@*') + self.assertBan('kban --nick --user foobar', 'foobar!user@*') + self.assertBan('kban --nick --host foobar', 'foobar!*@host.domain.tld') + self.assertBan('kban --user --host foobar', '*!user@host.domain.tld') + self.assertBan('kban --nick --user --host foobar', + 'foobar!user@host.domain.tld') self.assertNotRegexp('kban adlkfajsdlfkjsd', 'KeyError') self.assertNotRegexp('kban foobar time', 'ValueError') - self.assertError('kban %s' % self.nick) + self.assertError('kban %s' % self.irc.nick) def testLobotomizers(self): self.assertNotError('lobotomize') diff --git a/test/test_DCC.py b/test/test_DCC.py index 3a68c9606..c1158ef40 100644 --- a/test/test_DCC.py +++ b/test/test_DCC.py @@ -36,21 +36,22 @@ import telnetlib import ircutils -class DCCTestCase(PluginTestCase): - plugins = ('DCC', 'Utilities') - def testChat(self): - self.nick = 'foo' - self.prefix = 'foo!bar@baz' - self.irc.prefix = '%s!%s@localhost' % (self.irc.nick, self.irc.nick) - m = self.getMsg('chat [echo foo]') - time.sleep(.1) # Give it a second to bind the port. - self.failIf(ircutils.isChannel(m.args[0])) - s = m.args[1] - (ip, port) = s[15:-1].split() - ip = ircutils.unDccIP(long(ip)) - port = int(port) - t = telnetlib.Telnet(ip, port) - self.assertEqual(t.read_all(), 'foo\n') +if network: + class DCCTestCase(PluginTestCase): + plugins = ('DCC', 'Utilities') + def testChat(self): + self.nick = 'foo' + self.prefix = 'foo!bar@baz' + self.irc.prefix = '%s!%s@localhost' % (self.irc.nick, self.irc.nick) + m = self.getMsg('chat [echo foo]') + time.sleep(.1) # Give it a second to bind the port. + self.failIf(ircutils.isChannel(m.args[0])) + s = m.args[1] + (ip, port) = s[15:-1].split() + ip = ircutils.unDccIP(long(ip)) + port = int(port) + t = telnetlib.Telnet(ip, port) + self.assertEqual(t.read_all(), 'foo\n') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_Debian.py b/test/test_Debian.py index 7c1f2abf5..5fde8f1fc 100644 --- a/test/test_Debian.py +++ b/test/test_Debian.py @@ -34,46 +34,49 @@ import time from testsupport import * -class DebianTestCase(PluginTestCase, PluginDocumentation): - plugins = ('Debian',) - timeout = 100 - cleanDataDir = False - fileDownloaded = False +if network: + class DebianTestCase(PluginTestCase, PluginDocumentation): + plugins = ('Debian',) + timeout = 100 + cleanDataDir = False + fileDownloaded = False - def setUp(self, nick='test'): - PluginTestCase.setUp(self) - try: - if os.path.exists(os.path.join(conf.dataDir, 'Contents-i386.gz')): + def setUp(self, nick='test'): + PluginTestCase.setUp(self) + try: + if os.path.exists(os.path.join(conf.dataDir, + 'Contents-i386.gz')): + pass + else: + print + print "Downloading files, this may take awhile" + filename = os.path.join(conf.dataDir, 'Contents-i386.gz') + while not os.path.exists(filename): + time.sleep(1) + print "Download complete" + print "Starting test ..." + self.fileDownloaded = True + except KeyboardInterrupt: pass - else: - print - print "Downloading files, this may take awhile" - filename = os.path.join(conf.dataDir, 'Contents-i386.gz') - while not os.path.exists(filename): - time.sleep(1) - print "Download complete" - print "Starting test ..." - self.fileDownloaded = True - except KeyboardInterrupt: - pass - def testDebversion(self): - self.assertHelp('debian version') - self.assertRegexp('debian version lakjdfad', r'^No package.*\(all\)') - self.assertRegexp('debian version unstable alkdjfad', - r'^No package.*\(unstable\)') - self.assertRegexp('debian version gaim', - r'Total matches:.*gaim.*\(stable\)') - self.assertError('debian version unstable') + def testDebversion(self): + self.assertHelp('debian version') + self.assertRegexp('debian version lakjdfad', + r'^No package.*\(all\)') + self.assertRegexp('debian version unstable alkdjfad', + r'^No package.*\(unstable\)') + self.assertRegexp('debian version gaim', + r'Total matches:.*gaim.*\(stable\)') + self.assertError('debian version unstable') - def testDebfile(self): - self.assertHelp('file') - if not self.fileDownloaded: - pass - self.assertRegexp('file --exact bin/gaim', r'net/gaim') + def testDebfile(self): + self.assertHelp('file') + if not self.fileDownloaded: + pass + self.assertRegexp('file --exact bin/gaim', r'net/gaim') - def testDebincoming(self): - self.assertHelp('incoming') + def testDebincoming(self): + self.assertHelp('incoming') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_Dict.py b/test/test_Dict.py index 21944288d..ba05f2736 100644 --- a/test/test_Dict.py +++ b/test/test_Dict.py @@ -31,19 +31,19 @@ from testsupport import * -class DictTestCase(PluginTestCase, PluginDocumentation): - plugins = ('Dict', 'Misc') - def testDict(self): - self.assertNotError('dict slash') - self.assertNotRegexp('dict web1913 slash', 'foldoc') - self.assertNotError('dict ""') +if network: + class DictTestCase(PluginTestCase, PluginDocumentation): + plugins = ('Dict', 'Misc') + def testDict(self): + self.assertNotError('dict slash') + self.assertNotRegexp('dict web1913 slash', 'foldoc') + self.assertNotError('dict ""') - def testDictionaries(self): - self.assertNotError('dictionaries') + def testDictionaries(self): + self.assertNotError('dictionaries') - def testRandomDictionary(self): - self.assertNotError('random') - self.assertNotError('dict [random] moo') + def testRandomDictionary(self): + self.assertNotError('random') + self.assertNotError('dict [random] moo') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: - diff --git a/test/test_Ebay.py b/test/test_Ebay.py index bdde91322..e054726bb 100644 --- a/test/test_Ebay.py +++ b/test/test_Ebay.py @@ -31,45 +31,46 @@ from testsupport import * -class EbayTest(PluginTestCase, PluginDocumentation): - plugins = ('Ebay',) - def testAuction(self): - self.assertNotError('auction 3053641570') - # test 'Invalid Item' checking - self.assertRegexp('auction 2357056673', 'That auction is invalid') - self.assertError('auction foobar') +if network: + class EbayTest(PluginTestCase, PluginDocumentation): + plugins = ('Ebay',) + def testAuction(self): + self.assertNotError('auction 3053641570') + # test 'Invalid Item' checking + self.assertRegexp('auction 2357056673', 'That auction is invalid') + self.assertError('auction foobar') - def testSnarfer(self): - self.assertNotError('ebay config auction-snarfer on') - self.assertRegexp('http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem' - '&category=176&item=3053767552', - r'.*Cisco NP-4T.*Serial Module.*US \$74\.95.*') - self.assertRegexp('http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&' - 'category=28033&item=3053353651', - r'.*Cisco 2524 Router - NO RESERVE.*izontech \(.*') - # test snarfing other countries - self.assertRegexp('http://cgi.ebay.ca/ws/eBayISAPI.dll?ViewItem&' - 'item=3636820075', - r'NEW 34" Itech 8.8 Profile') - self.assertRegexp('http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&' - 'item=2355464443', - r'Any Clear Crazy') - self.assertRegexp('http://cgi.ebay.com.au/ws/eBayISAPI.dll?ViewItem&' - 'item=2762983161&category=4607', - r'Apple Mac G4') - # test .com/.*/ws/eBat compatibility - self.assertRegexp('http://cgi.ebay.com/ebaymotors/ws/eBayISAPI.dll?' - 'ViewItem&item=2439393310&category=33708', - r'88-89 CRX amber') + def testSnarfer(self): + self.assertNotError('ebay config auction-snarfer on') + self.assertRegexp('http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem' + '&category=176&item=3053767552', + r'.*Cisco NP-4T.*Serial Module.*US \$74\.95.*') + self.assertRegexp('http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&' + 'category=28033&item=3053353651', + r'.*Cisco 2524 Router - NO RESERVE.*izontech \(.*') + # test snarfing other countries + self.assertRegexp('http://cgi.ebay.ca/ws/eBayISAPI.dll?ViewItem&' + 'item=3636820075', + r'NEW 34" Itech 8.8 Profile') + self.assertRegexp('http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&' + 'item=2355464443', + r'Any Clear Crazy') + self.assertRegexp('http://cgi.ebay.com.au/ws/eBayISAPI.dll?ViewItem&' + 'item=2762983161&category=4607', + r'Apple Mac G4') + # test .com/.*/ws/eBat compatibility + self.assertRegexp('http://cgi.ebay.com/ebaymotors/ws/eBayISAPI.dll?' + 'ViewItem&item=2439393310&category=33708', + r'88-89 CRX amber') - def testConfigSnarfer(self): - self.assertNotError('ebay config auction-snarfer off') - self.assertNoResponse('http://cgi.ebay.com/ebaymotors/ws/' - 'eBayISAPI.dll?ViewItem&item=2439393310&' - 'category=33708') - self.assertNotError('ebay config auction-snarfer on') - self.assertNotError('http://cgi.ebay.com/ebaymotors/ws/' - 'eBayISAPI.dll?ViewItem&item=2439393310&' - 'category=33708') + def testConfigSnarfer(self): + self.assertNotError('ebay config auction-snarfer off') + self.assertNoResponse('http://cgi.ebay.com/ebaymotors/ws/' + 'eBayISAPI.dll?ViewItem&item=2439393310&' + 'category=33708') + self.assertNotError('ebay config auction-snarfer on') + self.assertNotError('http://cgi.ebay.com/ebaymotors/ws/' + 'eBayISAPI.dll?ViewItem&item=2439393310&' + 'category=33708') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_Gameknot.py b/test/test_Gameknot.py index 44cb3252d..725a8513c 100644 --- a/test/test_Gameknot.py +++ b/test/test_Gameknot.py @@ -33,50 +33,51 @@ from testsupport import * import utils -class GameknotTestCase(PluginTestCase, PluginDocumentation): - plugins = ('Gameknot',) - def testGkstats(self): - self.assertNotRegexp('gkstats jemfinch', 'Old GK rating') - self.assertError('gkstats %s' % utils.mktemp()) - self.assertNotError('gkstats Strike') +if network: + class GameknotTestCase(PluginTestCase, PluginDocumentation): + plugins = ('Gameknot',) + def testGkstats(self): + self.assertNotRegexp('gkstats jemfinch', 'Old GK rating') + self.assertError('gkstats %s' % utils.mktemp()) + self.assertNotError('gkstats Strike') - def testUrlSnarfer(self): - self.assertNotError('http://gameknot.com/chess.pl?bd=1019508') - self.assertNotError('here\'s a link: ' - 'http://gameknot.com/chess.pl?bd=1077350&r=394 ' - 'and here\'s another one: ' - 'http://gameknot.com/chess.pl?bd=1116828&r=250') - self.assertNotError(' ') # The next snarfed response. - self.assertNotRegexp('http://gameknot.com/chess.pl?bd=1019508', - self.nick) + def testUrlSnarfer(self): + self.assertNotError('http://gameknot.com/chess.pl?bd=1019508') + self.assertNotError('here\'s a link: ' + 'http://gameknot.com/chess.pl?bd=1077350&r=394 ' + 'and here\'s another one: ' + 'http://gameknot.com/chess.pl?bd=1116828&r=250') + self.assertNotError(' ') # The next snarfed response. + self.assertNotRegexp('http://gameknot.com/chess.pl?bd=1019508', + self.nick) - def testStatsUrlSnarfer(self): - self.assertNotError('http://gameknot.com/stats.pl?ironchefchess') - self.assertRegexp('http://gameknot.com/stats.pl?ddipaolo&1', - r'^[^&]+$') + def testStatsUrlSnarfer(self): + self.assertNotError('http://gameknot.com/stats.pl?ironchefchess') + self.assertRegexp('http://gameknot.com/stats.pl?ddipaolo&1', + r'^[^&]+$') - def testConfig(self): - self.assertNotError('gameknot config game-snarfer off') - self.assertNotError('gameknot config stats-snarfer off') - self.assertNoResponse('http://gameknot.com/stats.pl?ironchefchess') - self.assertNoResponse('http://gameknot.com/chess.pl?bd=907498') - self.assertNotError('gameknot config game-snarfer on') - self.assertNotError('gameknot config stats-snarfer on') - self.assertNotError('http://gameknot.com/stats.pl?ironchefchess') - self.assertNotError('http://gameknot.com/chess.pl?bd=907498') + def testConfig(self): + self.assertNotError('gameknot config game-snarfer off') + self.assertNotError('gameknot config stats-snarfer off') + self.assertNoResponse('http://gameknot.com/stats.pl?ironchefchess') + self.assertNoResponse('http://gameknot.com/chess.pl?bd=907498') + self.assertNotError('gameknot config game-snarfer on') + self.assertNotError('gameknot config stats-snarfer on') + self.assertNotError('http://gameknot.com/stats.pl?ironchefchess') + self.assertNotError('http://gameknot.com/chess.pl?bd=907498') - def testSnarfer(self): - # This game expired. -## self.assertRegexp('http://gameknot.com/chess.pl?bd=907498', -## '\x02ddipaolo\x0f won') - # As did this :( -## self.assertRegexp('http://gameknot.com/chess.pl?bd=907498', -## '\x02chroniqueur\x0f resigned') - self.assertRegexp('http://gameknot.com/chess.pl?bd=955432', - '\x02ddipaolo\x0f lost') - self.assertRegexp('http://gameknot.com/chess.pl?bd=1077345&r=365', - 'draw') + def testSnarfer(self): + # This game expired. +## self.assertRegexp('http://gameknot.com/chess.pl?bd=907498', +## '\x02ddipaolo\x0f won') + # As did this :( +## self.assertRegexp('http://gameknot.com/chess.pl?bd=907498', +## '\x02chroniqueur\x0f resigned') + self.assertRegexp('http://gameknot.com/chess.pl?bd=955432', + '\x02ddipaolo\x0f lost') + self.assertRegexp('http://gameknot.com/chess.pl?bd=1077345&r=365', + 'draw') diff --git a/test/test_Http.py b/test/test_Http.py index 213803e2e..0896d6359 100644 --- a/test/test_Http.py +++ b/test/test_Http.py @@ -31,90 +31,91 @@ from testsupport import * -class HttpTest(PluginTestCase, PluginDocumentation): - plugins = ('Http',) - def testExtension(self): - self.assertHelp('extension') - self.assertRegexp('extension doc', r'Microsoft\'s Word Document') - self.assertError('extension zapohd') - self.assertError('extension fo<') +if network: + class HttpTest(PluginTestCase, PluginDocumentation): + plugins = ('Http',) + def testExtension(self): + self.assertHelp('extension') + self.assertRegexp('extension doc', r'Microsoft\'s Word Document') + self.assertError('extension zapohd') + self.assertError('extension fo<') - def testHeaders(self): - self.assertError('headers ftp://ftp.cdrom.com/pub/linux') - self.assertNotError('headers http://www.slashdot.org/') + def testHeaders(self): + self.assertError('headers ftp://ftp.cdrom.com/pub/linux') + self.assertNotError('headers http://www.slashdot.org/') - def testDoctype(self): - self.assertError('doctype ftp://ftp.cdrom.com/pub/linux') - self.assertNotError('doctype http://www.slashdot.org/') - m = self.getMsg('doctype http://moobot.sf.net/') - self.failUnless(m.args[1].endswith('>')) + def testDoctype(self): + self.assertError('doctype ftp://ftp.cdrom.com/pub/linux') + self.assertNotError('doctype http://www.slashdot.org/') + m = self.getMsg('doctype http://moobot.sf.net/') + self.failUnless(m.args[1].endswith('>')) - def testSize(self): - self.assertError('size ftp://ftp.cdrom.com/pub/linux') - self.assertNotError('size http://supybot.sf.net/') - self.assertNotError('size http://www.slashdot.org/') + def testSize(self): + self.assertError('size ftp://ftp.cdrom.com/pub/linux') + self.assertNotError('size http://supybot.sf.net/') + self.assertNotError('size http://www.slashdot.org/') - def testStockquote(self): - self.assertNotError('stockquote MSFT') + def testStockquote(self): + self.assertNotError('stockquote MSFT') - def testFreshmeat(self): - self.assertNotError('freshmeat supybot') - self.assertNotError('freshmeat My Classifieds') - self.assertNotRegexp('freshmeat supybot', 'DOM Element') + def testFreshmeat(self): + self.assertNotError('freshmeat supybot') + self.assertNotError('freshmeat My Classifieds') + self.assertNotRegexp('freshmeat supybot', 'DOM Element') - def testTitle(self): - self.assertResponse('title slashdot.org', - 'Slashdot: News for nerds, stuff that matters') - self.assertResponse('title http://www.slashdot.org/', - 'Slashdot: News for nerds, stuff that matters') - self.assertNotRegexp('title ' - 'http://www.amazon.com/exec/obidos/tg/detail/-/' - '1884822312/qid=1063140754/sr=8-1/ref=sr_8_1/' - '002-9802970-2308826?v=glance&s=books&n=507846', - 'no HTML title') - # Checks the non-greediness of the regexp - self.assertResponse('title ' - 'http://www.space.com/scienceastronomy/' - 'jupiter_dark_spot_031023.html', - 'Mystery Spot on Jupiter Baffles Astronomers') - # Checks for @title not-working correctly - self.assertResponse('title '\ - 'http://www.catb.org/~esr/jargon/html/F/foo.html', - 'foo') + def testTitle(self): + self.assertResponse('title slashdot.org', + 'Slashdot: News for nerds, stuff that matters') + self.assertResponse('title http://www.slashdot.org/', + 'Slashdot: News for nerds, stuff that matters') + self.assertNotRegexp('title ' + 'http://www.amazon.com/exec/obidos/tg/detail/-/' + '1884822312/qid=1063140754/sr=8-1/ref=sr_8_1/' + '002-9802970-2308826?v=glance&s=books&n=507846', + 'no HTML title') + # Checks the non-greediness of the regexp + self.assertResponse('title ' + 'http://www.space.com/scienceastronomy/' + 'jupiter_dark_spot_031023.html', + 'Mystery Spot on Jupiter Baffles Astronomers') + # Checks for @title not-working correctly + self.assertResponse('title '\ + 'http://www.catb.org/~esr/jargon/html/F/foo.html', + 'foo') - def testGeekquote(self): - self.assertNotError('geekquote') - self.assertNotError('geekquote 4848') - # It's not an error, it just truncates at the first non-number - #self.assertError('geekquote 48a8') - self.assertError('geekquote asdf') + def testGeekquote(self): + self.assertNotError('geekquote') + self.assertNotError('geekquote 4848') + # It's not an error, it just truncates at the first non-number + #self.assertError('geekquote 48a8') + self.assertError('geekquote asdf') - def testAcronym(self): - self.assertRegexp('acronym ASAP', 'as soon as possible') - self.assertNotRegexp('acronym asap', 'Definition') - self.assertNotRegexp('acronym UNIX', 'not an acronym') - # Used to pass requests with spaces ... make sure that stays fixed - self.assertNotError('acronym W T F') + def testAcronym(self): + self.assertRegexp('acronym ASAP', 'as soon as possible') + self.assertNotRegexp('acronym asap', 'Definition') + self.assertNotRegexp('acronym UNIX', 'not an acronym') + # Used to pass requests with spaces ... make sure that stays fixed + self.assertNotError('acronym W T F') - def testNetcraft(self): - self.assertNotError('netcraft slashdot.org') + def testNetcraft(self): + self.assertNotError('netcraft slashdot.org') - def testWeather(self): - self.assertNotError('weather Columbus, OH') - self.assertNotError('weather 43221') - self.assertNotRegexp('weather Paris, FR', 'Virginia') - self.assertError('weather alsdkfjasdl, asdlfkjsadlfkj') - self.assertNotError('weather London, uk') - self.assertNotError('weather London, UK') - self.assertNotError('weather Munich, de') - self.assertNotError('weather Tucson, AZ') - self.assertError('weather hell') + def testWeather(self): + self.assertNotError('weather Columbus, OH') + self.assertNotError('weather 43221') + self.assertNotRegexp('weather Paris, FR', 'Virginia') + self.assertError('weather alsdkfjasdl, asdlfkjsadlfkj') + self.assertNotError('weather London, uk') + self.assertNotError('weather London, UK') + self.assertNotError('weather Munich, de') + self.assertNotError('weather Tucson, AZ') + self.assertError('weather hell') - def testKernel(self): - self.assertNotError('kernel') + def testKernel(self): + self.assertNotError('kernel') - def testPgpkey(self): - self.assertNotError('pgpkey jeremiah fincher') + def testPgpkey(self): + self.assertNotError('pgpkey jeremiah fincher') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_Misc.py b/test/test_Misc.py index 11246d3b2..8cdaac310 100644 --- a/test/test_Misc.py +++ b/test/test_Misc.py @@ -48,13 +48,14 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation): finally: conf.replyWhenNotCommand = False - def testNotReplyWhenRegexpsMatch(self): - try: - conf.replyWhenNotCommand = True - self.prefix = 'somethingElse!user@host.domain.tld' - self.assertNotError('http://gameknot.com/chess.pl?bd=1019508') - finally: - conf.replyWhenNotCommand = False + if network: + def testNotReplyWhenRegexpsMatch(self): + try: + conf.replyWhenNotCommand = True + self.prefix = 'somethingElse!user@host.domain.tld' + self.assertNotError('http://gameknot.com/chess.pl?bd=1019508') + finally: + conf.replyWhenNotCommand = False def testNotReplyWhenNotCanonicalName(self): try: diff --git a/test/test_Movies.py b/test/test_Movies.py index ee7892877..e5797f2b7 100644 --- a/test/test_Movies.py +++ b/test/test_Movies.py @@ -31,15 +31,16 @@ from testsupport import * -class MoviesTestCase(PluginTestCase, PluginDocumentation): - plugins = ('Movies',) - def testImdb(self): - self.assertNotError('imdb die hard') - self.assertRegexp('imdb kevin spacey', 'is apparently a person') +if network: + class MoviesTestCase(PluginTestCase, PluginDocumentation): + plugins = ('Movies',) + def testImdb(self): + self.assertNotError('imdb die hard') + self.assertRegexp('imdb kevin spacey', 'is apparently a person') - def testGenrePluralization(self): - self.assertNotRegexp('imdb 24', 'genres') - self.assertRegexp('imdb die hard', 'genres') + def testGenrePluralization(self): + self.assertNotRegexp('imdb 24', 'genres') + self.assertRegexp('imdb die hard', 'genres') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_Network.py b/test/test_Network.py index 6ce2a89d0..2fcf4ec4d 100644 --- a/test/test_Network.py +++ b/test/test_Network.py @@ -31,16 +31,18 @@ from testsupport import * -class NetworkTestCase(PluginTestCase, PluginDocumentation): - plugins = ['Network'] - def testDns(self): - self.assertNotError('dns slashdot.org') - self.assertResponse('dns alsdkjfaslkdfjaslkdfj.com', 'Host not found.') +if network: + class NetworkTestCase(PluginTestCase, PluginDocumentation): + plugins = ['Network'] + def testDns(self): + self.assertNotError('dns slashdot.org') + self.assertResponse('dns alsdkjfaslkdfjaslkdfj.com', + 'Host not found.') - def testWhois(self): - self.assertNotError('network whois ohio-state.edu') - self.assertError('network whois www.ohio-state.edu') - self.assertError('network whois slashdot.org') + def testWhois(self): + self.assertNotError('network whois ohio-state.edu') + self.assertError('network whois www.ohio-state.edu') + self.assertError('network whois slashdot.org') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_OSU.py b/test/test_OSU.py index f4f236292..179357e40 100644 --- a/test/test_OSU.py +++ b/test/test_OSU.py @@ -33,15 +33,18 @@ from testsupport import * class OSUTestCase(PluginTestCase, PluginDocumentation): plugins = ('OSU',) - def testOsuemail(self): - self.assertResponse('osu email jeremiah fincher', 'fincher.8@osu.edu') - self.assertResponse('osu email jeremiah d fincher','fincher.8@osu.edu') + if network: + def testOsuemail(self): + self.assertResponse('osu email jeremiah fincher', + 'fincher.8@osu.edu') + self.assertResponse('osu email jeremiah d fincher', + 'fincher.8@osu.edu') def testOsubuilding(self): - self.assertRegexp('osu building DL', '^Dreese Lab') - self.assertRegexp('osu building Dl', '^Dreese Lab') - self.assertRegexp('osu building dL', '^Dreese Lab') - self.assertRegexp('osu building dl', '^Dreese Lab') + self.assertRegexp('osu building DL', r'^Dreese Lab') + self.assertRegexp('osu building Dl', r'^Dreese Lab') + self.assertRegexp('osu building dL', r'^Dreese Lab') + self.assertRegexp('osu building dl', r'^Dreese Lab') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_Owner.py b/test/test_Owner.py index d05c7f61e..17afc5d26 100644 --- a/test/test_Owner.py +++ b/test/test_Owner.py @@ -36,14 +36,15 @@ import Owner class OwnerTestCase(PluginTestCase, PluginDocumentation): plugins = ('Utilities', 'Relay', 'Network', 'Admin', 'Channel') - def testDefaultPlugin(self): - self.assertError('whois osu.edu') - self.assertNotError('defaultplugin whois network') - self.assertNotError('whois osu.edu') - self.assertResponse('defaultplugin whois', 'network') - self.assertNotError('defaultplugin --remove whois') - self.assertError('whois osu.edu') - self.assertError('defaultplugin asdlfkjasdflkjsad Owner') + if network: + def testDefaultPlugin(self): + self.assertError('whois osu.edu') + self.assertNotError('defaultplugin whois network') + self.assertNotError('whois osu.edu') + self.assertResponse('defaultplugin whois', 'network') + self.assertNotError('defaultplugin --remove whois') + self.assertError('whois osu.edu') + self.assertError('defaultplugin asdlfkjasdflkjsad Owner') def testEval(self): try: diff --git a/test/test_Python.py b/test/test_Python.py index 8a8532183..6cba61d33 100644 --- a/test/test_Python.py +++ b/test/test_Python.py @@ -58,19 +58,20 @@ class PythonTestCase(PluginTestCase, PluginDocumentation): def testZen(self): self.assertNotError('zen') - def testAspnRecipes(self): - self.assertNotError('python config aspn-snarfer on') - self.assertRegexp('http://aspn.activestate.com/ASPN/Cookbook/Python/' - 'Recipe/230113', - 'Implementation of sets using sorted lists') + if network: + def testAspnRecipes(self): + self.assertNotError('python config aspn-snarfer on') + self.assertRegexp('http://aspn.activestate.com/ASPN/Cookbook/Python/' + 'Recipe/230113', + 'Implementation of sets using sorted lists') - def testConfig(self): - self.assertNotError('python config aspn-snarfer off') - self.assertNoResponse('http://aspn.activestate.com/ASPN/Cookbook/' - 'Python/Recipe/230113') - self.assertNotError('python config aspn-snarfer on') - self.assertNotError('http://aspn.activestate.com/ASPN/Cookbook/' - 'Python/Recipe/230113') + def testConfig(self): + self.assertNotError('python config aspn-snarfer off') + self.assertNoResponse('http://aspn.activestate.com/ASPN/Cookbook/' + 'Python/Recipe/230113') + self.assertNotError('python config aspn-snarfer on') + self.assertNotError('http://aspn.activestate.com/ASPN/Cookbook/' + 'Python/Recipe/230113') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_RSS.py b/test/test_RSS.py index 8249c934d..0e37f5c3b 100644 --- a/test/test_RSS.py +++ b/test/test_RSS.py @@ -32,31 +32,32 @@ from testsupport import * url = 'http://advogato.org/rss/articles.xml' -class RSSTestCase(PluginTestCase, PluginDocumentation): - plugins = ('RSS',) - def testRssinfo(self): - self.assertNotError('rss info %s' % url) +if network: + class RSSTestCase(PluginTestCase, PluginDocumentation): + plugins = ('RSS',) + def testRssinfo(self): + self.assertNotError('rss info %s' % url) - def testRssinfoDoesTimeProperly(self): - self.assertNotRegexp('rss info http://slashdot.org/slashdot.rss', - '-1 years') + def testRssinfoDoesTimeProperly(self): + self.assertNotRegexp('rss info http://slashdot.org/slashdot.rss', + '-1 years') - def testRss(self): - self.assertNotError('rss %s' % url) + def testRss(self): + self.assertNotError('rss %s' % url) - def testRssAdd(self): - self.assertNotError('rss add advogato %s' % url) - self.assertNotError('advogato') - self.assertNotError('rss advogato') - self.assertNotError('rss remove advogato') - self.assertError('advogato') - self.assertError('rss advogato') + def testRssAdd(self): + self.assertNotError('rss add advogato %s' % url) + self.assertNotError('advogato') + self.assertNotError('rss advogato') + self.assertNotError('rss remove advogato') + self.assertError('advogato') + self.assertError('rss advogato') - def testCantAddFeedNamedRss(self): - self.assertError('rss add rss %s' % url) + def testCantAddFeedNamedRss(self): + self.assertError('rss add rss %s' % url) - def testCantRemoveMethodThatIsntFeed(self): - self.assertError('rss remove rss') + def testCantRemoveMethodThatIsntFeed(self): + self.assertError('rss remove rss') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_Sourceforge.py b/test/test_Sourceforge.py index afc521f4f..81541c768 100644 --- a/test/test_Sourceforge.py +++ b/test/test_Sourceforge.py @@ -33,87 +33,88 @@ import re from testsupport import * -class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation): - plugins = ('Sourceforge',) - def testBug(self): - self.assertHelp('bug') - m = self.getMsg('bugs gaim') - self.failUnless(m, 'No response from Sourceforge.') - n = re.search('#(\d+)', m.args[1]).group(1) - self.assertNotError('bug gaim %s' % n) - self.assertError('bug gaim') - self.assertRegexp('bug lkadf 9', 'find the Bugs') +if network: + class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation): + plugins = ('Sourceforge',) + def testBug(self): + self.assertHelp('bug') + m = self.getMsg('bugs gaim') + self.failUnless(m, 'No response from Sourceforge.') + n = re.search('#(\d+)', m.args[1]).group(1) + self.assertNotError('bug gaim %s' % n) + self.assertError('bug gaim') + self.assertRegexp('bug lkadf 9', 'find the Bugs') - def testBugs(self): - self.assertHelp('bugs') - self.assertNotError('config defaultproject supybot') - self.assertNotError('bugs') - self.assertRegexp('bugs alkjfi83fa8', 'find the Bugs') - self.assertNotError('bugs gaim') - self.assertNotError('config defaultproject') - self.assertRegexp('bugs 83423', 'Use the bug command') + def testBugs(self): + self.assertHelp('bugs') + self.assertNotError('config defaultproject supybot') + self.assertNotError('bugs') + self.assertRegexp('bugs alkjfi83fa8', 'find the Bugs') + self.assertNotError('bugs gaim') + self.assertNotError('config defaultproject') + self.assertRegexp('bugs 83423', 'Use the bug command') - def testRfe(self): - m = self.getMsg('rfes gaim') - self.failUnless(m, 'No response from Sourceforge.') - n = re.search('#(\d+)', m.args[1]).group(1) - self.assertNotError('rfe gaim %s' % n) - self.assertError('rfe gaim') - self.assertRegexp('rfe lakdf 9', 'find the RFEs') + def testRfe(self): + m = self.getMsg('rfes gaim') + self.failUnless(m, 'No response from Sourceforge.') + n = re.search('#(\d+)', m.args[1]).group(1) + self.assertNotError('rfe gaim %s' % n) + self.assertError('rfe gaim') + self.assertRegexp('rfe lakdf 9', 'find the RFEs') - def testRfes(self): - self.assertHelp('rfes') - self.assertNotError('config defaultproject gaim') - self.assertNotError('rfes') - self.assertRegexp('rfes alkjfi83hfa8', 'find the RFEs') - self.assertNotError('rfes gaim') - self.assertNotError('config defaultproject') - self.assertRegexp('rfes 83423', 'Use the rfe command') + def testRfes(self): + self.assertHelp('rfes') + self.assertNotError('config defaultproject gaim') + self.assertNotError('rfes') + self.assertRegexp('rfes alkjfi83hfa8', 'find the RFEs') + self.assertNotError('rfes gaim') + self.assertNotError('config defaultproject') + self.assertRegexp('rfes 83423', 'Use the rfe command') - def testDefaultproject(self): - self.assertHelp('bugs') - self.assertNotError('config defaultproject supybot') - self.assertNotError('bugs') - m = self.getMsg('bugs') - n = re.search('#(\d+)', m.args[1]).group(1) - self.assertNotError('bug supybot %s' % n) - # This should have the same effect as calling 'bug supybot %s' - self.assertNotError('bug %s' % n) - self.assertNotError('config defaultproject ""') + def testDefaultproject(self): + self.assertHelp('bugs') + self.assertNotError('config defaultproject supybot') + self.assertNotError('bugs') + m = self.getMsg('bugs') + n = re.search('#(\d+)', m.args[1]).group(1) + self.assertNotError('bug supybot %s' % n) + # This should have the same effect as calling 'bug supybot %s' + self.assertNotError('bug %s' % n) + self.assertNotError('config defaultproject ""') - def testSnarfer(self): - s = r'.*Status.*: \w+' - self.assertNotError('config tracker-snarfer on') - self.assertRegexp('http://sourceforge.net/tracker/index.php?' - 'func=detail&aid=589953&group_id=58965&atid=489447', - s) - self.assertRegexp('http://sourceforge.net/tracker/index.php?' - 'func=detail&aid=712761&group_id=58965&atid=489450', - s) - self.assertRegexp('http://sourceforge.net/tracker/index.php?' - 'func=detail&aid=540223&group_id=235&atid=300235', s) - self.assertRegexp('http://sourceforge.net/tracker/index.php?' - 'func=detail&aid=561547&group_id=235&atid=200235', s) - self.assertRegexp('http://sourceforge.net/tracker/index.php?' - 'func=detail&aid=400942&group_id=235&atid=390395', s) + def testSnarfer(self): + s = r'.*Status.*: \w+' + self.assertNotError('config tracker-snarfer on') + self.assertRegexp('http://sourceforge.net/tracker/index.php?' + 'func=detail&aid=589953&group_id=58965&atid=489447', + s) + self.assertRegexp('http://sourceforge.net/tracker/index.php?' + 'func=detail&aid=712761&group_id=58965&atid=489450', + s) + self.assertRegexp('http://sourceforge.net/tracker/index.php?' + 'func=detail&aid=540223&group_id=235&atid=300235', s) + self.assertRegexp('http://sourceforge.net/tracker/index.php?' + 'func=detail&aid=561547&group_id=235&atid=200235', s) + self.assertRegexp('http://sourceforge.net/tracker/index.php?' + 'func=detail&aid=400942&group_id=235&atid=390395', s) - # test that it works without index.php - self.assertNotError('http://sourceforge.net/tracker/?' - 'func=detail&aid=540223&group_id=235&atid=300235') - # test that it works with www - self.assertNotError('http://www.sourceforge.net/tracker/index.php?' - 'func=detail&aid=540223&group_id=235&atid=300235') - # test that it works with www and without index.php - self.assertNotError('http://www.sourceforge.net/tracker/?' - 'func=detail&aid=540223&group_id=235&atid=300235') - # test that it works with sf.net - self.assertNotError('http://sf.net/tracker/?' - 'func=detail&aid=540223&group_id=235&atid=300235') - # test that it works - self.assertNotError('https://sourceforge.net/tracker/?' - 'func=detail&atid=105470&aid=827260&group_id=5470') - self.assertNoResponse('https://sourceforge.net/tracker/?' - 'group_id=58965&atid=489447') + # test that it works without index.php + self.assertNotError('http://sourceforge.net/tracker/?' + 'func=detail&aid=540223&group_id=235&atid=300235') + # test that it works with www + self.assertNotError('http://www.sourceforge.net/tracker/index.php?' + 'func=detail&aid=540223&group_id=235&atid=300235') + # test that it works with www and without index.php + self.assertNotError('http://www.sourceforge.net/tracker/?' + 'func=detail&aid=540223&group_id=235&atid=300235') + # test that it works with sf.net + self.assertNotError('http://sf.net/tracker/?' + 'func=detail&aid=540223&group_id=235&atid=300235') + # test that it works + self.assertNotError('https://sourceforge.net/tracker/?' + 'func=detail&atid=105470&aid=827260&group_id=5470') + self.assertNoResponse('https://sourceforge.net/tracker/?' + 'group_id=58965&atid=489447') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_URL.py b/test/test_URL.py index 75afc3195..af8f279da 100644 --- a/test/test_URL.py +++ b/test/test_URL.py @@ -100,30 +100,38 @@ if sqlite is not None: self.irc.feedMsg(ircmsgs.action(self.channel, urls[1])) self.assertNotRegexp('url last', '\\x01') - def testTinyurl(self): - self.assertNotError('url config tinyurlsnarfer off') - self.assertRegexp('url tiny http://sourceforge.net/tracker/?' - 'func=add&group_id=58965&atid=489447', - r'http://tinyurl.com/rqac') - self.assertNotError('url config tinyurlsnarfer on') - self.assertRegexp('url tiny http://sourceforge.net/tracker/?' - 'func=add&group_id=58965&atid=489447', - r'http://tinyurl.com/rqac') + def testNonSnarfingRegexpConfigurable(self): + self.assertNoResponse('http://foo.bar.baz/', 2) + self.assertResponse('url last', 'http://foo.bar.baz/') + self.assertNotError('url config non-snarfing-regexp m/biff/i') + self.assertNoResponse('http://biff.bar.baz/', 2) + self.assertResponse('url last', 'http://foo.bar.baz/') - def testTinysnarf(self): - self.assertNotError('url config tinyurlsnarfer on') - self.assertRegexp('http://sourceforge.net/tracker/?' - 'func=add&group_id=58965&atid=489447', - r'http://tinyurl.com/rqac.* \(was') - self.assertRegexp('http://www.urbandictionary.com/define.php?' - 'term=all+your+base+are+belong+to+us', - r'http://tinyurl.com/u479.* \(was') + if network: + def testTinyurl(self): + self.assertNotError('url config tinyurlsnarfer off') + self.assertRegexp('url tiny http://sourceforge.net/tracker/?' + 'func=add&group_id=58965&atid=489447', + r'http://tinyurl.com/rqac') + self.assertNotError('url config tinyurlsnarfer on') + self.assertRegexp('url tiny http://sourceforge.net/tracker/?' + 'func=add&group_id=58965&atid=489447', + r'http://tinyurl.com/rqac') - def testTitleSnarfer(self): - self.assertNoResponse('http://microsoft.com/') - self.assertNotError('url config title-snarfer on') - self.assertResponse('http://microsoft.com/', - 'Title: Microsoft Corporation') + def testTinysnarf(self): + self.assertNotError('url config tinyurlsnarfer on') + self.assertRegexp('http://sourceforge.net/tracker/?' + 'func=add&group_id=58965&atid=489447', + r'http://tinyurl.com/rqac.* \(was') + self.assertRegexp('http://www.urbandictionary.com/define.php?' + 'term=all+your+base+are+belong+to+us', + r'http://tinyurl.com/u479.* \(was') + + def testTitleSnarfer(self): + self.assertNoResponse('http://microsoft.com/') + self.assertNotError('url config title-snarfer on') + self.assertResponse('http://microsoft.com/', + 'Title: Microsoft Corporation') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: