Bladeren bron

Cleanup; ensure unit tests are functional

tags/v0.1^2
Ben Kurtovic 12 jaren geleden
bovenliggende
commit
e54db76757
3 gewijzigde bestanden met toevoegingen van 15 en 12 verwijderingen
  1. +2
    -2
      earwigbot/__init__.py
  2. +2
    -2
      earwigbot/irc/watcher.py
  3. +11
    -8
      earwigbot/tests/__init__.py

+ 2
- 2
earwigbot/__init__.py Bestand weergeven

@@ -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
)

+ 2
- 2
earwigbot/irc/watcher.py Bestand weergeven

@@ -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."""


+ 11
- 8
earwigbot/tests/__init__.py Bestand weergeven

@@ -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"

Laden…
Annuleren
Opslaan