3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

classes.Irc no longer needs a conf argument; tweak tests again

This commit is contained in:
James Lu 2015-08-28 19:38:16 -07:00
parent ad5fc97e21
commit b71e508acc
5 changed files with 12 additions and 23 deletions

View File

@ -9,6 +9,7 @@ import hashlib
from log import log
import utils
from conf import conf
### Exceptions
@ -55,7 +56,7 @@ class Irc():
# UID generators, for servers that need it
self.uidgen = {}
def __init__(self, netname, proto, conf):
def __init__(self, netname, proto):
# Initialize some variables
self.name = netname.lower()
self.conf = conf

View File

@ -23,7 +23,7 @@ testconf = {'bot':
'nick': 'PyLink',
'user': 'pylink',
'realname': 'PyLink Service Client',
'loglevel': 'DEBUG',
'loglevel': 'INFO',
'serverdesc': 'PyLink unit tests'
},
'servers':

View File

@ -11,23 +11,23 @@ import coreplugin
class TestProtoInspIRCd(unittest.TestCase):
def setUp(self):
self.irc = classes.FakeIRC('unittest', inspircd, classes.testconf)
self.irc = classes.FakeIRC('unittest', inspircd)
self.proto = self.irc.proto
self.sdata = self.irc.serverdata
# This is to initialize ourself as an internal PseudoServer, so we can spawn clients
self.proto.connect(self.irc)
self.irc.connect()
self.u = self.irc.pseudoclient.uid
self.maxDiff = None
utils.command_hooks = defaultdict(list)
self.initial_messages = self.irc.takeMsgs()
# Clear the hooks called at startup (spawnmain and possibly others)
self.irc.takeHooks()
def testConnect(self):
initial_messages = self.irc.takeMsgs()
commands = self.irc.takeCommands(initial_messages)
commands = self.irc.takeCommands(self.initial_messages)
# SERVER pylink.unittest abcd 0 9PY :PyLink Service
serverline = 'SERVER %s %s 0 %s :PyLink Service' % (
self.sdata['hostname'], self.sdata['sendpass'], self.sdata['sid'])
self.assertIn(serverline, initial_messages)
self.assertIn(serverline, self.initial_messages)
self.assertIn('BURST', commands)
self.assertIn('ENDBURST', commands)
# Is it creating our lovely PyLink PseudoClient?
@ -136,18 +136,6 @@ class TestProtoInspIRCd(unittest.TestCase):
self.assertNotIn('34Q', self.irc.servers)
self.assertNotIn('34Z', self.irc.servers)
def testRSquit(self):
u = self.proto.spawnClient(self.irc, 'person1', 'person', 'users.overdrive.pw')
u.identified = 'admin'
self.proto.spawnServer(self.irc, 'level1.pylink', '34P')
self.irc.run(':%s RSQUIT level1.pylink :some reason' % self.u)
# No SQUIT yet, since the 'PyLink' client isn't identified
self.assertNotIn('SQUIT', self.irc.takeCommands(self.irc.takeMsgs()))
# The one we just spawned however, is.
self.irc.run(':%s RSQUIT level1.pylink :some reason' % u.uid)
self.assertIn('SQUIT', self.irc.takeCommands(self.irc.takeMsgs()))
self.assertNotIn('34P', self.irc.servers)
def testHandleServer(self):
self.irc.run('SERVER whatever.net abcd 0 10X :something')
self.assertIn('10X', self.irc.servers)

View File

@ -14,7 +14,7 @@ def dummyf():
class TestRelay(unittest.TestCase):
def setUp(self):
self.irc = classes.FakeIRC('unittest', classes.FakeProto(), conf.testconf)
self.irc = classes.FakeIRC('unittest', classes.FakeProto())
self.irc.maxnicklen = 20
self.f = lambda nick: relay.normalizeNick(self.irc, 'unittest', nick)
# Fake our protocol name to something that supports slashes in nicks.

View File

@ -13,7 +13,7 @@ def dummyf():
class TestUtils(unittest.TestCase):
def setUp(self):
self.irc = classes.FakeIRC('fakeirc', classes.FakeProto(), conf.testconf)
self.irc = classes.FakeIRC('fakeirc', classes.FakeProto())
def testTS6UIDGenerator(self):
uidgen = utils.TS6UIDGenerator('9PY')