Added the --nonetwork and --noplugins flag.

This commit is contained in:
Jeremy Fincher 2004-01-01 19:51:48 +00:00
parent 1c0526666d
commit 87f3c2a644
20 changed files with 475 additions and 423 deletions

View File

@ -30,6 +30,7 @@
### ###
import supybot import supybot
import logging
import conf import conf
conf.dataDir = 'test-data' conf.dataDir = 'test-data'
@ -37,6 +38,7 @@ conf.confDir = 'test-conf'
conf.logDir = 'test-log' conf.logDir = 'test-log'
conf.replyWhenNotCommand = False conf.replyWhenNotCommand = False
conf.stdoutLogging = False conf.stdoutLogging = False
conf.minimumLogPriority = logging.DEBUG
conf.detailedTracebacks = False # Bugs in cgitb can be bad. conf.detailedTracebacks = False # Bugs in cgitb can be bad.
import fix import fix
@ -57,6 +59,7 @@ class path(str):
return self._r.split(self) == self._r.split(other) return self._r.split(self) == self._r.split(other)
if __name__ == '__main__': if __name__ == '__main__':
import testsupport
import optparse import optparse
if not os.path.exists(conf.dataDir): if not os.path.exists(conf.dataDir):
@ -68,11 +71,6 @@ if __name__ == '__main__':
if not os.path.exists(conf.logDir): if not os.path.exists(conf.logDir):
os.mkdir(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') pluginLogDir = os.path.join(conf.logDir, 'plugins')
for filename in os.listdir(pluginLogDir): for filename in os.listdir(pluginLogDir):
os.remove(os.path.join(pluginLogDir, filename)) os.remove(os.path.join(pluginLogDir, filename))
@ -92,9 +90,17 @@ if __name__ == '__main__':
parser.add_option('-v', '--verbose', action='store_true', default=False, parser.add_option('-v', '--verbose', action='store_true', default=False,
help='Sets the verbose flag, printing extra information ' help='Sets the verbose flag, printing extra information '
'about each test that runs.') '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() (options, args) = parser.parse_args()
if not 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: if options.exclusions:
for name in map(path, options.exclusions): for name in map(path, options.exclusions):
@ -113,6 +119,9 @@ if __name__ == '__main__':
else: else:
world.myVerbose = False world.myVerbose = False
if options.nonetwork:
testsupport.network = False
world.testing = True world.testing = True
names = [os.path.splitext(os.path.basename(name))[0] for name in args] names = [os.path.splitext(os.path.basename(name))[0] for name in args]
names.sort() names.sort()

View File

@ -33,7 +33,7 @@ from testsupport import *
LICENSE_KEY = 'INITIAL_NON_LICENSE_KEY' 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): class AmazonTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Amazon',) plugins = ('Amazon',)
def setUp(self): def setUp(self):

View File

@ -31,20 +31,21 @@
from testsupport import * from testsupport import *
class BabelFishTestCase(PluginTestCase, PluginDocumentation): if network:
plugins = ('Babelfish',) class BabelFishTestCase(PluginTestCase, PluginDocumentation):
def testTranslate(self): plugins = ('Babelfish',)
self.assertResponse('translate en sp food', def testTranslate(self):
'alimento') self.assertResponse('translate en sp food',
self.assertError('translate foo en food') 'alimento')
self.assertError('translate en foo food') self.assertError('translate foo en food')
self.assertError('translate en foo food')
def testBabelize(self): def testBabelize(self):
self.assertNotError('babelize en sp foo') self.assertNotError('babelize en sp foo')
self.assertError('babelize sp fr foo') self.assertError('babelize sp fr foo')
def testRandomlanguage(self): def testRandomlanguage(self):
self.assertNotError('randomlanguage') self.assertNotError('randomlanguage')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -31,26 +31,27 @@
from testsupport import * from testsupport import *
class BugzillaTest(PluginTestCase, PluginDocumentation): if network:
plugins = ('Bugzilla',) class BugzillaTest(PluginTestCase, PluginDocumentation):
def testBug(self): plugins = ('Bugzilla',)
self.assertNotError('bug gcc 5') def testBug(self):
self.assertNotError('bug gcc 5')
def testAddRemove(self): def testAddRemove(self):
self.assertNotError('add xiph http://bugs.xiph.org/ Xiph') self.assertNotError('add xiph http://bugs.xiph.org/ Xiph')
self.assertNotError('bug xiph 413') self.assertNotError('bug xiph 413')
self.assertNotError('remove xiph') self.assertNotError('remove xiph')
self.assertError('bug xiph 413') self.assertError('bug xiph 413')
def testSearch(self): def testSearch(self):
self.assertNotError('search gcc alpha') self.assertNotError('search gcc alpha')
self.assertNotError('search --keywords=fixed gcc alpha') self.assertNotError('search --keywords=fixed gcc alpha')
def testConfigBugzillaSnarfer(self): def testConfigBugzillaSnarfer(self):
self.assertNotError('bugzilla config bug-snarfer off') self.assertNotError('bugzilla config bug-snarfer off')
self.assertNoResponse('http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5') self.assertNoResponse('http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5')
self.assertNotError('bugzilla config bug-snarfer on') self.assertNotError('bugzilla config bug-snarfer on')
self.assertNotError('http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5') self.assertNotError('http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -87,17 +87,32 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation):
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick)) self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
self.assertNotError('voice') self.assertNotError('voice')
def testKban(self): def assertBan(self, query, hostmask, **kwargs):
self.irc.feedMsg(ircmsgs.join(self.channel, prefix='foobar!user@host')) m = self.getMsg(query, **kwargs)
self.assertError('kban foobar') self.assertEqual(m, ircmsgs.ban(self.channel, hostmask))
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
m = self.getMsg('kban foobar')
self.assertEqual(m, ircmsgs.ban(self.channel, '*!*@host'))
m = self.getMsg(' ') 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 adlkfajsdlfkjsd', 'KeyError')
self.assertNotRegexp('kban foobar time', 'ValueError') self.assertNotRegexp('kban foobar time', 'ValueError')
self.assertError('kban %s' % self.nick) self.assertError('kban %s' % self.irc.nick)
def testLobotomizers(self): def testLobotomizers(self):
self.assertNotError('lobotomize') self.assertNotError('lobotomize')

View File

@ -36,21 +36,22 @@ import telnetlib
import ircutils import ircutils
class DCCTestCase(PluginTestCase): if network:
plugins = ('DCC', 'Utilities') class DCCTestCase(PluginTestCase):
def testChat(self): plugins = ('DCC', 'Utilities')
self.nick = 'foo' def testChat(self):
self.prefix = 'foo!bar@baz' self.nick = 'foo'
self.irc.prefix = '%s!%s@localhost' % (self.irc.nick, self.irc.nick) self.prefix = 'foo!bar@baz'
m = self.getMsg('chat [echo foo]') self.irc.prefix = '%s!%s@localhost' % (self.irc.nick, self.irc.nick)
time.sleep(.1) # Give it a second to bind the port. m = self.getMsg('chat [echo foo]')
self.failIf(ircutils.isChannel(m.args[0])) time.sleep(.1) # Give it a second to bind the port.
s = m.args[1] self.failIf(ircutils.isChannel(m.args[0]))
(ip, port) = s[15:-1].split() s = m.args[1]
ip = ircutils.unDccIP(long(ip)) (ip, port) = s[15:-1].split()
port = int(port) ip = ircutils.unDccIP(long(ip))
t = telnetlib.Telnet(ip, port) port = int(port)
self.assertEqual(t.read_all(), 'foo\n') t = telnetlib.Telnet(ip, port)
self.assertEqual(t.read_all(), 'foo\n')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -34,46 +34,49 @@ import time
from testsupport import * from testsupport import *
class DebianTestCase(PluginTestCase, PluginDocumentation): if network:
plugins = ('Debian',) class DebianTestCase(PluginTestCase, PluginDocumentation):
timeout = 100 plugins = ('Debian',)
cleanDataDir = False timeout = 100
fileDownloaded = False cleanDataDir = False
fileDownloaded = False
def setUp(self, nick='test'): def setUp(self, nick='test'):
PluginTestCase.setUp(self) PluginTestCase.setUp(self)
try: try:
if os.path.exists(os.path.join(conf.dataDir, 'Contents-i386.gz')): 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 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): def testDebversion(self):
self.assertHelp('debian version') self.assertHelp('debian version')
self.assertRegexp('debian version lakjdfad', r'^No package.*\(all\)') self.assertRegexp('debian version lakjdfad',
self.assertRegexp('debian version unstable alkdjfad', r'^No package.*\(all\)')
r'^No package.*\(unstable\)') self.assertRegexp('debian version unstable alkdjfad',
self.assertRegexp('debian version gaim', r'^No package.*\(unstable\)')
r'Total matches:.*gaim.*\(stable\)') self.assertRegexp('debian version gaim',
self.assertError('debian version unstable') r'Total matches:.*gaim.*\(stable\)')
self.assertError('debian version unstable')
def testDebfile(self): def testDebfile(self):
self.assertHelp('file') self.assertHelp('file')
if not self.fileDownloaded: if not self.fileDownloaded:
pass pass
self.assertRegexp('file --exact bin/gaim', r'net/gaim') self.assertRegexp('file --exact bin/gaim', r'net/gaim')
def testDebincoming(self): def testDebincoming(self):
self.assertHelp('incoming') self.assertHelp('incoming')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -31,19 +31,19 @@
from testsupport import * from testsupport import *
class DictTestCase(PluginTestCase, PluginDocumentation): if network:
plugins = ('Dict', 'Misc') class DictTestCase(PluginTestCase, PluginDocumentation):
def testDict(self): plugins = ('Dict', 'Misc')
self.assertNotError('dict slash') def testDict(self):
self.assertNotRegexp('dict web1913 slash', 'foldoc') self.assertNotError('dict slash')
self.assertNotError('dict ""') self.assertNotRegexp('dict web1913 slash', 'foldoc')
self.assertNotError('dict ""')
def testDictionaries(self): def testDictionaries(self):
self.assertNotError('dictionaries') self.assertNotError('dictionaries')
def testRandomDictionary(self): def testRandomDictionary(self):
self.assertNotError('random') self.assertNotError('random')
self.assertNotError('dict [random] moo') self.assertNotError('dict [random] moo')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -31,45 +31,46 @@
from testsupport import * from testsupport import *
class EbayTest(PluginTestCase, PluginDocumentation): if network:
plugins = ('Ebay',) class EbayTest(PluginTestCase, PluginDocumentation):
def testAuction(self): plugins = ('Ebay',)
self.assertNotError('auction 3053641570') def testAuction(self):
# test 'Invalid Item' checking self.assertNotError('auction 3053641570')
self.assertRegexp('auction 2357056673', 'That auction is invalid') # test 'Invalid Item' checking
self.assertError('auction foobar') self.assertRegexp('auction 2357056673', 'That auction is invalid')
self.assertError('auction foobar')
def testSnarfer(self): def testSnarfer(self):
self.assertNotError('ebay config auction-snarfer on') self.assertNotError('ebay config auction-snarfer on')
self.assertRegexp('http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem' self.assertRegexp('http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem'
'&category=176&item=3053767552', '&category=176&item=3053767552',
r'.*Cisco NP-4T.*Serial Module.*US \$74\.95.*') r'.*Cisco NP-4T.*Serial Module.*US \$74\.95.*')
self.assertRegexp('http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&' self.assertRegexp('http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&'
'category=28033&item=3053353651', 'category=28033&item=3053353651',
r'.*Cisco 2524 Router - NO RESERVE.*izontech \(.*') r'.*Cisco 2524 Router - NO RESERVE.*izontech \(.*')
# test snarfing other countries # test snarfing other countries
self.assertRegexp('http://cgi.ebay.ca/ws/eBayISAPI.dll?ViewItem&' self.assertRegexp('http://cgi.ebay.ca/ws/eBayISAPI.dll?ViewItem&'
'item=3636820075', 'item=3636820075',
r'NEW 34" Itech 8.8 Profile') r'NEW 34" Itech 8.8 Profile')
self.assertRegexp('http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&' self.assertRegexp('http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&'
'item=2355464443', 'item=2355464443',
r'Any Clear Crazy') r'Any Clear Crazy')
self.assertRegexp('http://cgi.ebay.com.au/ws/eBayISAPI.dll?ViewItem&' self.assertRegexp('http://cgi.ebay.com.au/ws/eBayISAPI.dll?ViewItem&'
'item=2762983161&category=4607', 'item=2762983161&category=4607',
r'Apple Mac G4') r'Apple Mac G4')
# test .com/.*/ws/eBat compatibility # test .com/.*/ws/eBat compatibility
self.assertRegexp('http://cgi.ebay.com/ebaymotors/ws/eBayISAPI.dll?' self.assertRegexp('http://cgi.ebay.com/ebaymotors/ws/eBayISAPI.dll?'
'ViewItem&item=2439393310&category=33708', 'ViewItem&item=2439393310&category=33708',
r'88-89 CRX amber') r'88-89 CRX amber')
def testConfigSnarfer(self): def testConfigSnarfer(self):
self.assertNotError('ebay config auction-snarfer off') self.assertNotError('ebay config auction-snarfer off')
self.assertNoResponse('http://cgi.ebay.com/ebaymotors/ws/' self.assertNoResponse('http://cgi.ebay.com/ebaymotors/ws/'
'eBayISAPI.dll?ViewItem&item=2439393310&' 'eBayISAPI.dll?ViewItem&item=2439393310&'
'category=33708') 'category=33708')
self.assertNotError('ebay config auction-snarfer on') self.assertNotError('ebay config auction-snarfer on')
self.assertNotError('http://cgi.ebay.com/ebaymotors/ws/' self.assertNotError('http://cgi.ebay.com/ebaymotors/ws/'
'eBayISAPI.dll?ViewItem&item=2439393310&' 'eBayISAPI.dll?ViewItem&item=2439393310&'
'category=33708') 'category=33708')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -33,50 +33,51 @@ from testsupport import *
import utils import utils
class GameknotTestCase(PluginTestCase, PluginDocumentation): if network:
plugins = ('Gameknot',) class GameknotTestCase(PluginTestCase, PluginDocumentation):
def testGkstats(self): plugins = ('Gameknot',)
self.assertNotRegexp('gkstats jemfinch', 'Old GK rating') def testGkstats(self):
self.assertError('gkstats %s' % utils.mktemp()) self.assertNotRegexp('gkstats jemfinch', 'Old GK rating')
self.assertNotError('gkstats Strike') self.assertError('gkstats %s' % utils.mktemp())
self.assertNotError('gkstats Strike')
def testUrlSnarfer(self): def testUrlSnarfer(self):
self.assertNotError('http://gameknot.com/chess.pl?bd=1019508') self.assertNotError('http://gameknot.com/chess.pl?bd=1019508')
self.assertNotError('here\'s a link: ' self.assertNotError('here\'s a link: '
'http://gameknot.com/chess.pl?bd=1077350&r=394 ' 'http://gameknot.com/chess.pl?bd=1077350&r=394 '
'and here\'s another one: ' 'and here\'s another one: '
'http://gameknot.com/chess.pl?bd=1116828&r=250') 'http://gameknot.com/chess.pl?bd=1116828&r=250')
self.assertNotError(' ') # The next snarfed response. self.assertNotError(' ') # The next snarfed response.
self.assertNotRegexp('http://gameknot.com/chess.pl?bd=1019508', self.assertNotRegexp('http://gameknot.com/chess.pl?bd=1019508',
self.nick) self.nick)
def testStatsUrlSnarfer(self): def testStatsUrlSnarfer(self):
self.assertNotError('http://gameknot.com/stats.pl?ironchefchess') self.assertNotError('http://gameknot.com/stats.pl?ironchefchess')
self.assertRegexp('http://gameknot.com/stats.pl?ddipaolo&1', self.assertRegexp('http://gameknot.com/stats.pl?ddipaolo&1',
r'^[^&]+$') r'^[^&]+$')
def testConfig(self): def testConfig(self):
self.assertNotError('gameknot config game-snarfer off') self.assertNotError('gameknot config game-snarfer off')
self.assertNotError('gameknot config stats-snarfer off') self.assertNotError('gameknot config stats-snarfer off')
self.assertNoResponse('http://gameknot.com/stats.pl?ironchefchess') self.assertNoResponse('http://gameknot.com/stats.pl?ironchefchess')
self.assertNoResponse('http://gameknot.com/chess.pl?bd=907498') self.assertNoResponse('http://gameknot.com/chess.pl?bd=907498')
self.assertNotError('gameknot config game-snarfer on') self.assertNotError('gameknot config game-snarfer on')
self.assertNotError('gameknot config stats-snarfer on') self.assertNotError('gameknot config stats-snarfer on')
self.assertNotError('http://gameknot.com/stats.pl?ironchefchess') self.assertNotError('http://gameknot.com/stats.pl?ironchefchess')
self.assertNotError('http://gameknot.com/chess.pl?bd=907498') self.assertNotError('http://gameknot.com/chess.pl?bd=907498')
def testSnarfer(self): def testSnarfer(self):
# This game expired. # This game expired.
## self.assertRegexp('http://gameknot.com/chess.pl?bd=907498', ## self.assertRegexp('http://gameknot.com/chess.pl?bd=907498',
## '\x02ddipaolo\x0f won') ## '\x02ddipaolo\x0f won')
# As did this :( # As did this :(
## self.assertRegexp('http://gameknot.com/chess.pl?bd=907498', ## self.assertRegexp('http://gameknot.com/chess.pl?bd=907498',
## '\x02chroniqueur\x0f resigned') ## '\x02chroniqueur\x0f resigned')
self.assertRegexp('http://gameknot.com/chess.pl?bd=955432', self.assertRegexp('http://gameknot.com/chess.pl?bd=955432',
'\x02ddipaolo\x0f lost') '\x02ddipaolo\x0f lost')
self.assertRegexp('http://gameknot.com/chess.pl?bd=1077345&r=365', self.assertRegexp('http://gameknot.com/chess.pl?bd=1077345&r=365',
'draw') 'draw')

View File

@ -31,90 +31,91 @@
from testsupport import * from testsupport import *
class HttpTest(PluginTestCase, PluginDocumentation): if network:
plugins = ('Http',) class HttpTest(PluginTestCase, PluginDocumentation):
def testExtension(self): plugins = ('Http',)
self.assertHelp('extension') def testExtension(self):
self.assertRegexp('extension doc', r'Microsoft\'s Word Document') self.assertHelp('extension')
self.assertError('extension zapohd') self.assertRegexp('extension doc', r'Microsoft\'s Word Document')
self.assertError('extension fo<') self.assertError('extension zapohd')
self.assertError('extension fo<')
def testHeaders(self): def testHeaders(self):
self.assertError('headers ftp://ftp.cdrom.com/pub/linux') self.assertError('headers ftp://ftp.cdrom.com/pub/linux')
self.assertNotError('headers http://www.slashdot.org/') self.assertNotError('headers http://www.slashdot.org/')
def testDoctype(self): def testDoctype(self):
self.assertError('doctype ftp://ftp.cdrom.com/pub/linux') self.assertError('doctype ftp://ftp.cdrom.com/pub/linux')
self.assertNotError('doctype http://www.slashdot.org/') self.assertNotError('doctype http://www.slashdot.org/')
m = self.getMsg('doctype http://moobot.sf.net/') m = self.getMsg('doctype http://moobot.sf.net/')
self.failUnless(m.args[1].endswith('>')) self.failUnless(m.args[1].endswith('>'))
def testSize(self): def testSize(self):
self.assertError('size ftp://ftp.cdrom.com/pub/linux') self.assertError('size ftp://ftp.cdrom.com/pub/linux')
self.assertNotError('size http://supybot.sf.net/') self.assertNotError('size http://supybot.sf.net/')
self.assertNotError('size http://www.slashdot.org/') self.assertNotError('size http://www.slashdot.org/')
def testStockquote(self): def testStockquote(self):
self.assertNotError('stockquote MSFT') self.assertNotError('stockquote MSFT')
def testFreshmeat(self): def testFreshmeat(self):
self.assertNotError('freshmeat supybot') self.assertNotError('freshmeat supybot')
self.assertNotError('freshmeat My Classifieds') self.assertNotError('freshmeat My Classifieds')
self.assertNotRegexp('freshmeat supybot', 'DOM Element') self.assertNotRegexp('freshmeat supybot', 'DOM Element')
def testTitle(self): def testTitle(self):
self.assertResponse('title slashdot.org', self.assertResponse('title slashdot.org',
'Slashdot: News for nerds, stuff that matters') 'Slashdot: News for nerds, stuff that matters')
self.assertResponse('title http://www.slashdot.org/', self.assertResponse('title http://www.slashdot.org/',
'Slashdot: News for nerds, stuff that matters') 'Slashdot: News for nerds, stuff that matters')
self.assertNotRegexp('title ' self.assertNotRegexp('title '
'http://www.amazon.com/exec/obidos/tg/detail/-/' 'http://www.amazon.com/exec/obidos/tg/detail/-/'
'1884822312/qid=1063140754/sr=8-1/ref=sr_8_1/' '1884822312/qid=1063140754/sr=8-1/ref=sr_8_1/'
'002-9802970-2308826?v=glance&s=books&n=507846', '002-9802970-2308826?v=glance&s=books&n=507846',
'no HTML title') 'no HTML title')
# Checks the non-greediness of the regexp # Checks the non-greediness of the regexp
self.assertResponse('title ' self.assertResponse('title '
'http://www.space.com/scienceastronomy/' 'http://www.space.com/scienceastronomy/'
'jupiter_dark_spot_031023.html', 'jupiter_dark_spot_031023.html',
'Mystery Spot on Jupiter Baffles Astronomers') 'Mystery Spot on Jupiter Baffles Astronomers')
# Checks for @title not-working correctly # Checks for @title not-working correctly
self.assertResponse('title '\ self.assertResponse('title '\
'http://www.catb.org/~esr/jargon/html/F/foo.html', 'http://www.catb.org/~esr/jargon/html/F/foo.html',
'foo') 'foo')
def testGeekquote(self): def testGeekquote(self):
self.assertNotError('geekquote') self.assertNotError('geekquote')
self.assertNotError('geekquote 4848') self.assertNotError('geekquote 4848')
# It's not an error, it just truncates at the first non-number # It's not an error, it just truncates at the first non-number
#self.assertError('geekquote 48a8') #self.assertError('geekquote 48a8')
self.assertError('geekquote asdf') self.assertError('geekquote asdf')
def testAcronym(self): def testAcronym(self):
self.assertRegexp('acronym ASAP', 'as soon as possible') self.assertRegexp('acronym ASAP', 'as soon as possible')
self.assertNotRegexp('acronym asap', 'Definition') self.assertNotRegexp('acronym asap', 'Definition')
self.assertNotRegexp('acronym UNIX', 'not an acronym') self.assertNotRegexp('acronym UNIX', 'not an acronym')
# Used to pass requests with spaces ... make sure that stays fixed # Used to pass requests with spaces ... make sure that stays fixed
self.assertNotError('acronym W T F') self.assertNotError('acronym W T F')
def testNetcraft(self): def testNetcraft(self):
self.assertNotError('netcraft slashdot.org') self.assertNotError('netcraft slashdot.org')
def testWeather(self): def testWeather(self):
self.assertNotError('weather Columbus, OH') self.assertNotError('weather Columbus, OH')
self.assertNotError('weather 43221') self.assertNotError('weather 43221')
self.assertNotRegexp('weather Paris, FR', 'Virginia') self.assertNotRegexp('weather Paris, FR', 'Virginia')
self.assertError('weather alsdkfjasdl, asdlfkjsadlfkj') self.assertError('weather alsdkfjasdl, asdlfkjsadlfkj')
self.assertNotError('weather London, uk') self.assertNotError('weather London, uk')
self.assertNotError('weather London, UK') self.assertNotError('weather London, UK')
self.assertNotError('weather Munich, de') self.assertNotError('weather Munich, de')
self.assertNotError('weather Tucson, AZ') self.assertNotError('weather Tucson, AZ')
self.assertError('weather hell') self.assertError('weather hell')
def testKernel(self): def testKernel(self):
self.assertNotError('kernel') self.assertNotError('kernel')
def testPgpkey(self): def testPgpkey(self):
self.assertNotError('pgpkey jeremiah fincher') self.assertNotError('pgpkey jeremiah fincher')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -48,13 +48,14 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
finally: finally:
conf.replyWhenNotCommand = False conf.replyWhenNotCommand = False
def testNotReplyWhenRegexpsMatch(self): if network:
try: def testNotReplyWhenRegexpsMatch(self):
conf.replyWhenNotCommand = True try:
self.prefix = 'somethingElse!user@host.domain.tld' conf.replyWhenNotCommand = True
self.assertNotError('http://gameknot.com/chess.pl?bd=1019508') self.prefix = 'somethingElse!user@host.domain.tld'
finally: self.assertNotError('http://gameknot.com/chess.pl?bd=1019508')
conf.replyWhenNotCommand = False finally:
conf.replyWhenNotCommand = False
def testNotReplyWhenNotCanonicalName(self): def testNotReplyWhenNotCanonicalName(self):
try: try:

View File

@ -31,15 +31,16 @@
from testsupport import * from testsupport import *
class MoviesTestCase(PluginTestCase, PluginDocumentation): if network:
plugins = ('Movies',) class MoviesTestCase(PluginTestCase, PluginDocumentation):
def testImdb(self): plugins = ('Movies',)
self.assertNotError('imdb die hard') def testImdb(self):
self.assertRegexp('imdb kevin spacey', 'is apparently a person') self.assertNotError('imdb die hard')
self.assertRegexp('imdb kevin spacey', 'is apparently a person')
def testGenrePluralization(self): def testGenrePluralization(self):
self.assertNotRegexp('imdb 24', 'genres') self.assertNotRegexp('imdb 24', 'genres')
self.assertRegexp('imdb die hard', 'genres') self.assertRegexp('imdb die hard', 'genres')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -31,16 +31,18 @@
from testsupport import * from testsupport import *
class NetworkTestCase(PluginTestCase, PluginDocumentation): if network:
plugins = ['Network'] class NetworkTestCase(PluginTestCase, PluginDocumentation):
def testDns(self): plugins = ['Network']
self.assertNotError('dns slashdot.org') def testDns(self):
self.assertResponse('dns alsdkjfaslkdfjaslkdfj.com', 'Host not found.') self.assertNotError('dns slashdot.org')
self.assertResponse('dns alsdkjfaslkdfjaslkdfj.com',
'Host not found.')
def testWhois(self): def testWhois(self):
self.assertNotError('network whois ohio-state.edu') self.assertNotError('network whois ohio-state.edu')
self.assertError('network whois www.ohio-state.edu') self.assertError('network whois www.ohio-state.edu')
self.assertError('network whois slashdot.org') self.assertError('network whois slashdot.org')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -33,15 +33,18 @@ from testsupport import *
class OSUTestCase(PluginTestCase, PluginDocumentation): class OSUTestCase(PluginTestCase, PluginDocumentation):
plugins = ('OSU',) plugins = ('OSU',)
def testOsuemail(self): if network:
self.assertResponse('osu email jeremiah fincher', 'fincher.8@osu.edu') def testOsuemail(self):
self.assertResponse('osu email jeremiah d fincher','fincher.8@osu.edu') self.assertResponse('osu email jeremiah fincher',
'fincher.8@osu.edu')
self.assertResponse('osu email jeremiah d fincher',
'fincher.8@osu.edu')
def testOsubuilding(self): def testOsubuilding(self):
self.assertRegexp('osu building DL', '^Dreese Lab') self.assertRegexp('osu building DL', r'^Dreese Lab')
self.assertRegexp('osu building Dl', '^Dreese Lab') self.assertRegexp('osu building Dl', r'^Dreese Lab')
self.assertRegexp('osu building dL', '^Dreese Lab') self.assertRegexp('osu building dL', r'^Dreese Lab')
self.assertRegexp('osu building dl', '^Dreese Lab') self.assertRegexp('osu building dl', r'^Dreese Lab')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -36,14 +36,15 @@ import Owner
class OwnerTestCase(PluginTestCase, PluginDocumentation): class OwnerTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Utilities', 'Relay', 'Network', 'Admin', 'Channel') plugins = ('Utilities', 'Relay', 'Network', 'Admin', 'Channel')
def testDefaultPlugin(self): if network:
self.assertError('whois osu.edu') def testDefaultPlugin(self):
self.assertNotError('defaultplugin whois network') self.assertError('whois osu.edu')
self.assertNotError('whois osu.edu') self.assertNotError('defaultplugin whois network')
self.assertResponse('defaultplugin whois', 'network') self.assertNotError('whois osu.edu')
self.assertNotError('defaultplugin --remove whois') self.assertResponse('defaultplugin whois', 'network')
self.assertError('whois osu.edu') self.assertNotError('defaultplugin --remove whois')
self.assertError('defaultplugin asdlfkjasdflkjsad Owner') self.assertError('whois osu.edu')
self.assertError('defaultplugin asdlfkjasdflkjsad Owner')
def testEval(self): def testEval(self):
try: try:

View File

@ -58,19 +58,20 @@ class PythonTestCase(PluginTestCase, PluginDocumentation):
def testZen(self): def testZen(self):
self.assertNotError('zen') self.assertNotError('zen')
def testAspnRecipes(self): if network:
self.assertNotError('python config aspn-snarfer on') def testAspnRecipes(self):
self.assertRegexp('http://aspn.activestate.com/ASPN/Cookbook/Python/' self.assertNotError('python config aspn-snarfer on')
'Recipe/230113', self.assertRegexp('http://aspn.activestate.com/ASPN/Cookbook/Python/'
'Implementation of sets using sorted lists') 'Recipe/230113',
'Implementation of sets using sorted lists')
def testConfig(self): def testConfig(self):
self.assertNotError('python config aspn-snarfer off') self.assertNotError('python config aspn-snarfer off')
self.assertNoResponse('http://aspn.activestate.com/ASPN/Cookbook/' self.assertNoResponse('http://aspn.activestate.com/ASPN/Cookbook/'
'Python/Recipe/230113') 'Python/Recipe/230113')
self.assertNotError('python config aspn-snarfer on') self.assertNotError('python config aspn-snarfer on')
self.assertNotError('http://aspn.activestate.com/ASPN/Cookbook/' self.assertNotError('http://aspn.activestate.com/ASPN/Cookbook/'
'Python/Recipe/230113') 'Python/Recipe/230113')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -32,31 +32,32 @@
from testsupport import * from testsupport import *
url = 'http://advogato.org/rss/articles.xml' url = 'http://advogato.org/rss/articles.xml'
class RSSTestCase(PluginTestCase, PluginDocumentation): if network:
plugins = ('RSS',) class RSSTestCase(PluginTestCase, PluginDocumentation):
def testRssinfo(self): plugins = ('RSS',)
self.assertNotError('rss info %s' % url) def testRssinfo(self):
self.assertNotError('rss info %s' % url)
def testRssinfoDoesTimeProperly(self): def testRssinfoDoesTimeProperly(self):
self.assertNotRegexp('rss info http://slashdot.org/slashdot.rss', self.assertNotRegexp('rss info http://slashdot.org/slashdot.rss',
'-1 years') '-1 years')
def testRss(self): def testRss(self):
self.assertNotError('rss %s' % url) self.assertNotError('rss %s' % url)
def testRssAdd(self): def testRssAdd(self):
self.assertNotError('rss add advogato %s' % url) self.assertNotError('rss add advogato %s' % url)
self.assertNotError('advogato') self.assertNotError('advogato')
self.assertNotError('rss advogato') self.assertNotError('rss advogato')
self.assertNotError('rss remove advogato') self.assertNotError('rss remove advogato')
self.assertError('advogato') self.assertError('advogato')
self.assertError('rss advogato') self.assertError('rss advogato')
def testCantAddFeedNamedRss(self): def testCantAddFeedNamedRss(self):
self.assertError('rss add rss %s' % url) self.assertError('rss add rss %s' % url)
def testCantRemoveMethodThatIsntFeed(self): def testCantRemoveMethodThatIsntFeed(self):
self.assertError('rss remove rss') self.assertError('rss remove rss')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -33,87 +33,88 @@ import re
from testsupport import * from testsupport import *
class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation): if network:
plugins = ('Sourceforge',) class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation):
def testBug(self): plugins = ('Sourceforge',)
self.assertHelp('bug') def testBug(self):
m = self.getMsg('bugs gaim') self.assertHelp('bug')
self.failUnless(m, 'No response from Sourceforge.') m = self.getMsg('bugs gaim')
n = re.search('#(\d+)', m.args[1]).group(1) self.failUnless(m, 'No response from Sourceforge.')
self.assertNotError('bug gaim %s' % n) n = re.search('#(\d+)', m.args[1]).group(1)
self.assertError('bug gaim') self.assertNotError('bug gaim %s' % n)
self.assertRegexp('bug lkadf 9', 'find the Bugs') self.assertError('bug gaim')
self.assertRegexp('bug lkadf 9', 'find the Bugs')
def testBugs(self): def testBugs(self):
self.assertHelp('bugs') self.assertHelp('bugs')
self.assertNotError('config defaultproject supybot') self.assertNotError('config defaultproject supybot')
self.assertNotError('bugs') self.assertNotError('bugs')
self.assertRegexp('bugs alkjfi83fa8', 'find the Bugs') self.assertRegexp('bugs alkjfi83fa8', 'find the Bugs')
self.assertNotError('bugs gaim') self.assertNotError('bugs gaim')
self.assertNotError('config defaultproject') self.assertNotError('config defaultproject')
self.assertRegexp('bugs 83423', 'Use the bug command') self.assertRegexp('bugs 83423', 'Use the bug command')
def testRfe(self): def testRfe(self):
m = self.getMsg('rfes gaim') m = self.getMsg('rfes gaim')
self.failUnless(m, 'No response from Sourceforge.') self.failUnless(m, 'No response from Sourceforge.')
n = re.search('#(\d+)', m.args[1]).group(1) n = re.search('#(\d+)', m.args[1]).group(1)
self.assertNotError('rfe gaim %s' % n) self.assertNotError('rfe gaim %s' % n)
self.assertError('rfe gaim') self.assertError('rfe gaim')
self.assertRegexp('rfe lakdf 9', 'find the RFEs') self.assertRegexp('rfe lakdf 9', 'find the RFEs')
def testRfes(self): def testRfes(self):
self.assertHelp('rfes') self.assertHelp('rfes')
self.assertNotError('config defaultproject gaim') self.assertNotError('config defaultproject gaim')
self.assertNotError('rfes') self.assertNotError('rfes')
self.assertRegexp('rfes alkjfi83hfa8', 'find the RFEs') self.assertRegexp('rfes alkjfi83hfa8', 'find the RFEs')
self.assertNotError('rfes gaim') self.assertNotError('rfes gaim')
self.assertNotError('config defaultproject') self.assertNotError('config defaultproject')
self.assertRegexp('rfes 83423', 'Use the rfe command') self.assertRegexp('rfes 83423', 'Use the rfe command')
def testDefaultproject(self): def testDefaultproject(self):
self.assertHelp('bugs') self.assertHelp('bugs')
self.assertNotError('config defaultproject supybot') self.assertNotError('config defaultproject supybot')
self.assertNotError('bugs') self.assertNotError('bugs')
m = self.getMsg('bugs') m = self.getMsg('bugs')
n = re.search('#(\d+)', m.args[1]).group(1) n = re.search('#(\d+)', m.args[1]).group(1)
self.assertNotError('bug supybot %s' % n) self.assertNotError('bug supybot %s' % n)
# This should have the same effect as calling 'bug supybot %s' # This should have the same effect as calling 'bug supybot %s'
self.assertNotError('bug %s' % n) self.assertNotError('bug %s' % n)
self.assertNotError('config defaultproject ""') self.assertNotError('config defaultproject ""')
def testSnarfer(self): def testSnarfer(self):
s = r'.*Status.*: \w+' s = r'.*Status.*: \w+'
self.assertNotError('config tracker-snarfer on') self.assertNotError('config tracker-snarfer on')
self.assertRegexp('http://sourceforge.net/tracker/index.php?' self.assertRegexp('http://sourceforge.net/tracker/index.php?'
'func=detail&aid=589953&group_id=58965&atid=489447', 'func=detail&aid=589953&group_id=58965&atid=489447',
s) s)
self.assertRegexp('http://sourceforge.net/tracker/index.php?' self.assertRegexp('http://sourceforge.net/tracker/index.php?'
'func=detail&aid=712761&group_id=58965&atid=489450', 'func=detail&aid=712761&group_id=58965&atid=489450',
s) s)
self.assertRegexp('http://sourceforge.net/tracker/index.php?' self.assertRegexp('http://sourceforge.net/tracker/index.php?'
'func=detail&aid=540223&group_id=235&atid=300235', s) 'func=detail&aid=540223&group_id=235&atid=300235', s)
self.assertRegexp('http://sourceforge.net/tracker/index.php?' self.assertRegexp('http://sourceforge.net/tracker/index.php?'
'func=detail&aid=561547&group_id=235&atid=200235', s) 'func=detail&aid=561547&group_id=235&atid=200235', s)
self.assertRegexp('http://sourceforge.net/tracker/index.php?' self.assertRegexp('http://sourceforge.net/tracker/index.php?'
'func=detail&aid=400942&group_id=235&atid=390395', s) 'func=detail&aid=400942&group_id=235&atid=390395', s)
# test that it works without index.php # test that it works without index.php
self.assertNotError('http://sourceforge.net/tracker/?' self.assertNotError('http://sourceforge.net/tracker/?'
'func=detail&aid=540223&group_id=235&atid=300235') 'func=detail&aid=540223&group_id=235&atid=300235')
# test that it works with www # test that it works with www
self.assertNotError('http://www.sourceforge.net/tracker/index.php?' self.assertNotError('http://www.sourceforge.net/tracker/index.php?'
'func=detail&aid=540223&group_id=235&atid=300235') 'func=detail&aid=540223&group_id=235&atid=300235')
# test that it works with www and without index.php # test that it works with www and without index.php
self.assertNotError('http://www.sourceforge.net/tracker/?' self.assertNotError('http://www.sourceforge.net/tracker/?'
'func=detail&aid=540223&group_id=235&atid=300235') 'func=detail&aid=540223&group_id=235&atid=300235')
# test that it works with sf.net # test that it works with sf.net
self.assertNotError('http://sf.net/tracker/?' self.assertNotError('http://sf.net/tracker/?'
'func=detail&aid=540223&group_id=235&atid=300235') 'func=detail&aid=540223&group_id=235&atid=300235')
# test that it works # test that it works
self.assertNotError('https://sourceforge.net/tracker/?' self.assertNotError('https://sourceforge.net/tracker/?'
'func=detail&atid=105470&aid=827260&group_id=5470') 'func=detail&atid=105470&aid=827260&group_id=5470')
self.assertNoResponse('https://sourceforge.net/tracker/?' self.assertNoResponse('https://sourceforge.net/tracker/?'
'group_id=58965&atid=489447') 'group_id=58965&atid=489447')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -100,30 +100,38 @@ if sqlite is not None:
self.irc.feedMsg(ircmsgs.action(self.channel, urls[1])) self.irc.feedMsg(ircmsgs.action(self.channel, urls[1]))
self.assertNotRegexp('url last', '\\x01') self.assertNotRegexp('url last', '\\x01')
def testTinyurl(self): def testNonSnarfingRegexpConfigurable(self):
self.assertNotError('url config tinyurlsnarfer off') self.assertNoResponse('http://foo.bar.baz/', 2)
self.assertRegexp('url tiny http://sourceforge.net/tracker/?' self.assertResponse('url last', 'http://foo.bar.baz/')
'func=add&group_id=58965&atid=489447', self.assertNotError('url config non-snarfing-regexp m/biff/i')
r'http://tinyurl.com/rqac') self.assertNoResponse('http://biff.bar.baz/', 2)
self.assertNotError('url config tinyurlsnarfer on') self.assertResponse('url last', 'http://foo.bar.baz/')
self.assertRegexp('url tiny http://sourceforge.net/tracker/?'
'func=add&group_id=58965&atid=489447',
r'http://tinyurl.com/rqac')
def testTinysnarf(self): if network:
self.assertNotError('url config tinyurlsnarfer on') def testTinyurl(self):
self.assertRegexp('http://sourceforge.net/tracker/?' self.assertNotError('url config tinyurlsnarfer off')
'func=add&group_id=58965&atid=489447', self.assertRegexp('url tiny http://sourceforge.net/tracker/?'
r'http://tinyurl.com/rqac.* \(was') 'func=add&group_id=58965&atid=489447',
self.assertRegexp('http://www.urbandictionary.com/define.php?' r'http://tinyurl.com/rqac')
'term=all+your+base+are+belong+to+us', self.assertNotError('url config tinyurlsnarfer on')
r'http://tinyurl.com/u479.* \(was') self.assertRegexp('url tiny http://sourceforge.net/tracker/?'
'func=add&group_id=58965&atid=489447',
r'http://tinyurl.com/rqac')
def testTitleSnarfer(self): def testTinysnarf(self):
self.assertNoResponse('http://microsoft.com/') self.assertNotError('url config tinyurlsnarfer on')
self.assertNotError('url config title-snarfer on') self.assertRegexp('http://sourceforge.net/tracker/?'
self.assertResponse('http://microsoft.com/', 'func=add&group_id=58965&atid=489447',
'Title: Microsoft Corporation') 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: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: