diff --git a/classes.py b/classes.py index 8f24742..14a0a83 100644 --- a/classes.py +++ b/classes.py @@ -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 diff --git a/conf.py b/conf.py index f1e6bee..a70f37b 100644 --- a/conf.py +++ b/conf.py @@ -23,7 +23,7 @@ testconf = {'bot': 'nick': 'PyLink', 'user': 'pylink', 'realname': 'PyLink Service Client', - 'loglevel': 'DEBUG', + 'loglevel': 'INFO', 'serverdesc': 'PyLink unit tests' }, 'servers': diff --git a/tests/test_proto_inspircd.py b/tests/test_proto_inspircd.py index 01eac64..62ee417 100644 --- a/tests/test_proto_inspircd.py +++ b/tests/test_proto_inspircd.py @@ -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) diff --git a/tests/test_relay.py b/tests/test_relay.py index 0f82299..1cbfbc6 100644 --- a/tests/test_relay.py +++ b/tests/test_relay.py @@ -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. diff --git a/tests/test_utils.py b/tests/test_utils.py index 2a6f904..795f108 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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')