mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 14:14:37 +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 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()
|
||||
|
@ -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):
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
from testsupport import *
|
||||
|
||||
if network:
|
||||
class BabelFishTestCase(PluginTestCase, PluginDocumentation):
|
||||
plugins = ('Babelfish',)
|
||||
def testTranslate(self):
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
from testsupport import *
|
||||
|
||||
if network:
|
||||
class BugzillaTest(PluginTestCase, PluginDocumentation):
|
||||
plugins = ('Bugzilla',)
|
||||
def testBug(self):
|
||||
|
@ -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')
|
||||
|
@ -36,6 +36,7 @@ import telnetlib
|
||||
|
||||
import ircutils
|
||||
|
||||
if network:
|
||||
class DCCTestCase(PluginTestCase):
|
||||
plugins = ('DCC', 'Utilities')
|
||||
def testChat(self):
|
||||
|
@ -34,6 +34,7 @@ import time
|
||||
|
||||
from testsupport import *
|
||||
|
||||
if network:
|
||||
class DebianTestCase(PluginTestCase, PluginDocumentation):
|
||||
plugins = ('Debian',)
|
||||
timeout = 100
|
||||
@ -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',
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
from testsupport import *
|
||||
|
||||
if network:
|
||||
class DictTestCase(PluginTestCase, PluginDocumentation):
|
||||
plugins = ('Dict', 'Misc')
|
||||
def testDict(self):
|
||||
@ -46,4 +47,3 @@ class DictTestCase(PluginTestCase, PluginDocumentation):
|
||||
self.assertNotError('dict [random] moo')
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
from testsupport import *
|
||||
|
||||
if network:
|
||||
class EbayTest(PluginTestCase, PluginDocumentation):
|
||||
plugins = ('Ebay',)
|
||||
def testAuction(self):
|
||||
|
@ -33,6 +33,7 @@ from testsupport import *
|
||||
|
||||
import utils
|
||||
|
||||
if network:
|
||||
class GameknotTestCase(PluginTestCase, PluginDocumentation):
|
||||
plugins = ('Gameknot',)
|
||||
def testGkstats(self):
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
from testsupport import *
|
||||
|
||||
if network:
|
||||
class HttpTest(PluginTestCase, PluginDocumentation):
|
||||
plugins = ('Http',)
|
||||
def testExtension(self):
|
||||
|
@ -48,6 +48,7 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
|
||||
finally:
|
||||
conf.replyWhenNotCommand = False
|
||||
|
||||
if network:
|
||||
def testNotReplyWhenRegexpsMatch(self):
|
||||
try:
|
||||
conf.replyWhenNotCommand = True
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
from testsupport import *
|
||||
|
||||
if network:
|
||||
class MoviesTestCase(PluginTestCase, PluginDocumentation):
|
||||
plugins = ('Movies',)
|
||||
def testImdb(self):
|
||||
|
@ -31,11 +31,13 @@
|
||||
|
||||
from testsupport import *
|
||||
|
||||
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')
|
||||
|
@ -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:
|
||||
|
@ -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')
|
||||
|
@ -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/'
|
||||
|
@ -32,6 +32,7 @@
|
||||
from testsupport import *
|
||||
|
||||
url = 'http://advogato.org/rss/articles.xml'
|
||||
if network:
|
||||
class RSSTestCase(PluginTestCase, PluginDocumentation):
|
||||
plugins = ('RSS',)
|
||||
def testRssinfo(self):
|
||||
|
@ -33,6 +33,7 @@ import re
|
||||
|
||||
from testsupport import *
|
||||
|
||||
if network:
|
||||
class SourceforgeTest(ChannelPluginTestCase, PluginDocumentation):
|
||||
plugins = ('Sourceforge',)
|
||||
def testBug(self):
|
||||
|
@ -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/?'
|
||||
|
Loading…
Reference in New Issue
Block a user