From e54db76757c41adf8bab330a47b4e3f700c7cf32 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sat, 24 Mar 2012 13:55:28 -0400 Subject: [PATCH] Cleanup; ensure unit tests are functional --- earwigbot/__init__.py | 4 ++-- earwigbot/irc/watcher.py | 4 ++-- earwigbot/tests/__init__.py | 19 +++++++++++-------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/earwigbot/__init__.py b/earwigbot/__init__.py index 0da7679..50da3f6 100644 --- a/earwigbot/__init__.py +++ b/earwigbot/__init__.py @@ -32,6 +32,6 @@ __version__ = "0.1.dev" __email__ = "ben.kurtovic@verizon.net" from earwigbot import ( - blowfish, config, classes, commands, config, frontend, main, rules, tasks, - tests, watcher, wiki + blowfish, config, classes, commands, config, irc, main, rules, runner, + tasks, tests, wiki ) diff --git a/earwigbot/irc/watcher.py b/earwigbot/irc/watcher.py index 020b209..e06559a 100644 --- a/earwigbot/irc/watcher.py +++ b/earwigbot/irc/watcher.py @@ -40,13 +40,13 @@ class Watcher(IRCConnection): """ def __init__(self, frontend=None): - logger = logging.getLogger("earwigbot.watcher") + self.logger = logging.getLogger("earwigbot.watcher") cf = config.irc["watcher"] base = super(Frontend, self) base.__init__(cf["host"], cf["port"], cf["nick"], cf["ident"], cf["realname"], self.logger) - self._connect() self.frontend = frontend + self._connect() def _process_message(self, line): """Process a single message from IRC.""" diff --git a/earwigbot/tests/__init__.py b/earwigbot/tests/__init__.py index bd2c481..c3e6ac3 100644 --- a/earwigbot/tests/__init__.py +++ b/earwigbot/tests/__init__.py @@ -34,18 +34,18 @@ instead of a socket for data. import re from unittest import TestCase -from earwigbot.classes import Connection, Data +from earwigbot.irc import IRCConnection, Data class CommandTestCase(TestCase): re_sender = re.compile(":(.*?)!(.*?)@(.*?)\Z") def setUp(self, command): self.connection = FakeConnection() - self.connection.connect() + self.connection._connect() self.command = command(self.connection) def get_single(self): - data = self.connection.get().split("\n") + data = self.connection._get().split("\n") line = data.pop(0) for remaining in data[1:]: self.connection.send(remaining) @@ -92,16 +92,19 @@ class CommandTestCase(TestCase): line = ":Foo!bar@example.com JOIN :#channel".strip().split() return self.maker(line, line[2][1:]) -class FakeConnection(Connection): - def connect(self): +class FakeConnection(IRCConnection): + def __init__(self): + pass + + def _connect(self): self._buffer = "" - def close(self): + def _close(self): pass - def get(self, size=4096): + def _get(self, size=4096): data, self._buffer = self._buffer, "" return data - def send(self, msg): + def _send(self, msg): self._buffer += msg + "\n"