mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 22:24:20 +01:00
Added the --nonetwork and --noplugins flag.
This commit is contained in:
parent
1c0526666d
commit
87f3c2a644
21
test/test.py
21
test/test.py
@ -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()
|
||||||
|
@ -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):
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
from testsupport import *
|
from testsupport import *
|
||||||
|
|
||||||
|
if network:
|
||||||
class BabelFishTestCase(PluginTestCase, PluginDocumentation):
|
class BabelFishTestCase(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Babelfish',)
|
plugins = ('Babelfish',)
|
||||||
def testTranslate(self):
|
def testTranslate(self):
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
from testsupport import *
|
from testsupport import *
|
||||||
|
|
||||||
|
if network:
|
||||||
class BugzillaTest(PluginTestCase, PluginDocumentation):
|
class BugzillaTest(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Bugzilla',)
|
plugins = ('Bugzilla',)
|
||||||
def testBug(self):
|
def testBug(self):
|
||||||
|
@ -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')
|
||||||
|
@ -36,6 +36,7 @@ import telnetlib
|
|||||||
|
|
||||||
import ircutils
|
import ircutils
|
||||||
|
|
||||||
|
if network:
|
||||||
class DCCTestCase(PluginTestCase):
|
class DCCTestCase(PluginTestCase):
|
||||||
plugins = ('DCC', 'Utilities')
|
plugins = ('DCC', 'Utilities')
|
||||||
def testChat(self):
|
def testChat(self):
|
||||||
|
@ -34,6 +34,7 @@ import time
|
|||||||
|
|
||||||
from testsupport import *
|
from testsupport import *
|
||||||
|
|
||||||
|
if network:
|
||||||
class DebianTestCase(PluginTestCase, PluginDocumentation):
|
class DebianTestCase(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Debian',)
|
plugins = ('Debian',)
|
||||||
timeout = 100
|
timeout = 100
|
||||||
@ -43,7 +44,8 @@ class DebianTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
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
|
pass
|
||||||
else:
|
else:
|
||||||
print
|
print
|
||||||
@ -59,7 +61,8 @@ class DebianTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
|
|
||||||
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',
|
||||||
|
r'^No package.*\(all\)')
|
||||||
self.assertRegexp('debian version unstable alkdjfad',
|
self.assertRegexp('debian version unstable alkdjfad',
|
||||||
r'^No package.*\(unstable\)')
|
r'^No package.*\(unstable\)')
|
||||||
self.assertRegexp('debian version gaim',
|
self.assertRegexp('debian version gaim',
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
from testsupport import *
|
from testsupport import *
|
||||||
|
|
||||||
|
if network:
|
||||||
class DictTestCase(PluginTestCase, PluginDocumentation):
|
class DictTestCase(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Dict', 'Misc')
|
plugins = ('Dict', 'Misc')
|
||||||
def testDict(self):
|
def testDict(self):
|
||||||
@ -46,4 +47,3 @@ class DictTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
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:
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
from testsupport import *
|
from testsupport import *
|
||||||
|
|
||||||
|
if network:
|
||||||
class EbayTest(PluginTestCase, PluginDocumentation):
|
class EbayTest(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Ebay',)
|
plugins = ('Ebay',)
|
||||||
def testAuction(self):
|
def testAuction(self):
|
||||||
|
@ -33,6 +33,7 @@ from testsupport import *
|
|||||||
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
|
if network:
|
||||||
class GameknotTestCase(PluginTestCase, PluginDocumentation):
|
class GameknotTestCase(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Gameknot',)
|
plugins = ('Gameknot',)
|
||||||
def testGkstats(self):
|
def testGkstats(self):
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
from testsupport import *
|
from testsupport import *
|
||||||
|
|
||||||
|
if network:
|
||||||
class HttpTest(PluginTestCase, PluginDocumentation):
|
class HttpTest(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Http',)
|
plugins = ('Http',)
|
||||||
def testExtension(self):
|
def testExtension(self):
|
||||||
|
@ -48,6 +48,7 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
finally:
|
finally:
|
||||||
conf.replyWhenNotCommand = False
|
conf.replyWhenNotCommand = False
|
||||||
|
|
||||||
|
if network:
|
||||||
def testNotReplyWhenRegexpsMatch(self):
|
def testNotReplyWhenRegexpsMatch(self):
|
||||||
try:
|
try:
|
||||||
conf.replyWhenNotCommand = True
|
conf.replyWhenNotCommand = True
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
from testsupport import *
|
from testsupport import *
|
||||||
|
|
||||||
|
if network:
|
||||||
class MoviesTestCase(PluginTestCase, PluginDocumentation):
|
class MoviesTestCase(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Movies',)
|
plugins = ('Movies',)
|
||||||
def testImdb(self):
|
def testImdb(self):
|
||||||
|
@ -31,11 +31,13 @@
|
|||||||
|
|
||||||
from testsupport import *
|
from testsupport import *
|
||||||
|
|
||||||
|
if network:
|
||||||
class NetworkTestCase(PluginTestCase, PluginDocumentation):
|
class NetworkTestCase(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ['Network']
|
plugins = ['Network']
|
||||||
def testDns(self):
|
def testDns(self):
|
||||||
self.assertNotError('dns slashdot.org')
|
self.assertNotError('dns slashdot.org')
|
||||||
self.assertResponse('dns alsdkjfaslkdfjaslkdfj.com', 'Host not found.')
|
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')
|
||||||
|
@ -33,15 +33,18 @@ from testsupport import *
|
|||||||
|
|
||||||
class OSUTestCase(PluginTestCase, PluginDocumentation):
|
class OSUTestCase(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('OSU',)
|
plugins = ('OSU',)
|
||||||
|
if network:
|
||||||
def testOsuemail(self):
|
def testOsuemail(self):
|
||||||
self.assertResponse('osu email jeremiah fincher', 'fincher.8@osu.edu')
|
self.assertResponse('osu email jeremiah fincher',
|
||||||
self.assertResponse('osu email jeremiah d fincher','fincher.8@osu.edu')
|
'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:
|
||||||
|
@ -36,6 +36,7 @@ import Owner
|
|||||||
|
|
||||||
class OwnerTestCase(PluginTestCase, PluginDocumentation):
|
class OwnerTestCase(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Utilities', 'Relay', 'Network', 'Admin', 'Channel')
|
plugins = ('Utilities', 'Relay', 'Network', 'Admin', 'Channel')
|
||||||
|
if network:
|
||||||
def testDefaultPlugin(self):
|
def testDefaultPlugin(self):
|
||||||
self.assertError('whois osu.edu')
|
self.assertError('whois osu.edu')
|
||||||
self.assertNotError('defaultplugin whois network')
|
self.assertNotError('defaultplugin whois network')
|
||||||
|
@ -58,6 +58,7 @@ class PythonTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
def testZen(self):
|
def testZen(self):
|
||||||
self.assertNotError('zen')
|
self.assertNotError('zen')
|
||||||
|
|
||||||
|
if network:
|
||||||
def testAspnRecipes(self):
|
def testAspnRecipes(self):
|
||||||
self.assertNotError('python config aspn-snarfer on')
|
self.assertNotError('python config aspn-snarfer on')
|
||||||
self.assertRegexp('http://aspn.activestate.com/ASPN/Cookbook/Python/'
|
self.assertRegexp('http://aspn.activestate.com/ASPN/Cookbook/Python/'
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
from testsupport import *
|
from testsupport import *
|
||||||
|
|
||||||
url = 'http://advogato.org/rss/articles.xml'
|
url = 'http://advogato.org/rss/articles.xml'
|
||||||
|
if network:
|
||||||
class RSSTestCase(PluginTestCase, PluginDocumentation):
|
class RSSTestCase(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('RSS',)
|
plugins = ('RSS',)
|
||||||
def testRssinfo(self):
|
def testRssinfo(self):
|
||||||
|
@ -33,6 +33,7 @@ import re
|
|||||||
|
|
||||||
from testsupport import *
|
from testsupport import *
|
||||||
|
|
||||||
|
if network:
|
||||||
class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation):
|
class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Sourceforge',)
|
plugins = ('Sourceforge',)
|
||||||
def testBug(self):
|
def testBug(self):
|
||||||
|
@ -100,6 +100,14 @@ 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 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):
|
def testTinyurl(self):
|
||||||
self.assertNotError('url config tinyurlsnarfer off')
|
self.assertNotError('url config tinyurlsnarfer off')
|
||||||
self.assertRegexp('url tiny http://sourceforge.net/tracker/?'
|
self.assertRegexp('url tiny http://sourceforge.net/tracker/?'
|
||||||
|
Loading…
Reference in New Issue
Block a user