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 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()

View File

@ -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):

View File

@ -31,7 +31,8 @@
from testsupport import *
class BabelFishTestCase(PluginTestCase, PluginDocumentation):
if network:
class BabelFishTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Babelfish',)
def testTranslate(self):
self.assertResponse('translate en sp food',

View File

@ -31,7 +31,8 @@
from testsupport import *
class BugzillaTest(PluginTestCase, PluginDocumentation):
if network:
class BugzillaTest(PluginTestCase, PluginDocumentation):
plugins = ('Bugzilla',)
def testBug(self):
self.assertNotError('bug gcc 5')

View File

@ -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')

View File

@ -36,7 +36,8 @@ import telnetlib
import ircutils
class DCCTestCase(PluginTestCase):
if network:
class DCCTestCase(PluginTestCase):
plugins = ('DCC', 'Utilities')
def testChat(self):
self.nick = 'foo'

View File

@ -34,7 +34,8 @@ import time
from testsupport import *
class DebianTestCase(PluginTestCase, PluginDocumentation):
if network:
class DebianTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Debian',)
timeout = 100
cleanDataDir = False
@ -43,7 +44,8 @@ class DebianTestCase(PluginTestCase, PluginDocumentation):
def setUp(self, nick='test'):
PluginTestCase.setUp(self)
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
@ -59,7 +61,8 @@ class DebianTestCase(PluginTestCase, PluginDocumentation):
def testDebversion(self):
self.assertHelp('debian version')
self.assertRegexp('debian version lakjdfad', r'^No package.*\(all\)')
self.assertRegexp('debian version lakjdfad',
r'^No package.*\(all\)')
self.assertRegexp('debian version unstable alkdjfad',
r'^No package.*\(unstable\)')
self.assertRegexp('debian version gaim',

View File

@ -31,7 +31,8 @@
from testsupport import *
class DictTestCase(PluginTestCase, PluginDocumentation):
if network:
class DictTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Dict', 'Misc')
def testDict(self):
self.assertNotError('dict slash')
@ -46,4 +47,3 @@ class DictTestCase(PluginTestCase, PluginDocumentation):
self.assertNotError('dict [random] moo')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -31,7 +31,8 @@
from testsupport import *
class EbayTest(PluginTestCase, PluginDocumentation):
if network:
class EbayTest(PluginTestCase, PluginDocumentation):
plugins = ('Ebay',)
def testAuction(self):
self.assertNotError('auction 3053641570')

View File

@ -33,7 +33,8 @@ from testsupport import *
import utils
class GameknotTestCase(PluginTestCase, PluginDocumentation):
if network:
class GameknotTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Gameknot',)
def testGkstats(self):
self.assertNotRegexp('gkstats jemfinch', 'Old GK rating')

View File

@ -31,7 +31,8 @@
from testsupport import *
class HttpTest(PluginTestCase, PluginDocumentation):
if network:
class HttpTest(PluginTestCase, PluginDocumentation):
plugins = ('Http',)
def testExtension(self):
self.assertHelp('extension')

View File

@ -48,6 +48,7 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
finally:
conf.replyWhenNotCommand = False
if network:
def testNotReplyWhenRegexpsMatch(self):
try:
conf.replyWhenNotCommand = True

View File

@ -31,7 +31,8 @@
from testsupport import *
class MoviesTestCase(PluginTestCase, PluginDocumentation):
if network:
class MoviesTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Movies',)
def testImdb(self):
self.assertNotError('imdb die hard')

View File

@ -31,11 +31,13 @@
from testsupport import *
class NetworkTestCase(PluginTestCase, PluginDocumentation):
if network:
class NetworkTestCase(PluginTestCase, PluginDocumentation):
plugins = ['Network']
def testDns(self):
self.assertNotError('dns slashdot.org')
self.assertResponse('dns alsdkjfaslkdfjaslkdfj.com', 'Host not found.')
self.assertResponse('dns alsdkjfaslkdfjaslkdfj.com',
'Host not found.')
def testWhois(self):
self.assertNotError('network whois ohio-state.edu')

View File

@ -33,15 +33,18 @@ from testsupport import *
class OSUTestCase(PluginTestCase, PluginDocumentation):
plugins = ('OSU',)
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')
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:

View File

@ -36,6 +36,7 @@ import Owner
class OwnerTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Utilities', 'Relay', 'Network', 'Admin', 'Channel')
if network:
def testDefaultPlugin(self):
self.assertError('whois osu.edu')
self.assertNotError('defaultplugin whois network')

View File

@ -58,6 +58,7 @@ class PythonTestCase(PluginTestCase, PluginDocumentation):
def testZen(self):
self.assertNotError('zen')
if network:
def testAspnRecipes(self):
self.assertNotError('python config aspn-snarfer on')
self.assertRegexp('http://aspn.activestate.com/ASPN/Cookbook/Python/'

View File

@ -32,7 +32,8 @@
from testsupport import *
url = 'http://advogato.org/rss/articles.xml'
class RSSTestCase(PluginTestCase, PluginDocumentation):
if network:
class RSSTestCase(PluginTestCase, PluginDocumentation):
plugins = ('RSS',)
def testRssinfo(self):
self.assertNotError('rss info %s' % url)

View File

@ -33,7 +33,8 @@ import re
from testsupport import *
class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation):
if network:
class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation):
plugins = ('Sourceforge',)
def testBug(self):
self.assertHelp('bug')

View File

@ -100,6 +100,14 @@ if sqlite is not None:
self.irc.feedMsg(ircmsgs.action(self.channel, urls[1]))
self.assertNotRegexp('url last', '\\x01')
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/')
if network:
def testTinyurl(self):
self.assertNotError('url config tinyurlsnarfer off')
self.assertRegexp('url tiny http://sourceforge.net/tracker/?'