From f45cb3a5836803ba1e22e533384e6e239930f1ca Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 28 Jul 2016 22:03:44 -0700 Subject: [PATCH] classes: Drop FakeIRC, FakeProto --- classes.py | 71 ------------------------------------------------------ 1 file changed, 71 deletions(-) diff --git a/classes.py b/classes.py index 84f41c6..165e68f 100644 --- a/classes.py +++ b/classes.py @@ -1346,74 +1346,3 @@ class Protocol(): """ prefixsearch = re.search(r'\(([A-Za-z]+)\)(.*)', args) return dict(zip(prefixsearch.group(1), prefixsearch.group(2))) - -### FakeIRC classes, used for test cases - -class FakeIRC(Irc): - """Fake IRC object used for unit tests.""" - def connect(self): - self.messages = [] - self.hookargs = [] - self.hookmsgs = [] - self.socket = None - self.initVars() - self.connected = threading.Event() - self.connected.set() - - def run(self, data): - """Queues a message to the fake IRC server.""" - log.debug('<- ' + data) - hook_args = self.proto.handle_events(data) - if hook_args is not None: - self.hookmsgs.append(hook_args) - self.callHooks(hook_args) - - def send(self, data): - self.messages.append(data) - log.debug('-> ' + data) - - def takeMsgs(self): - """Returns a list of messages sent by the protocol module since - the last takeMsgs() call, so we can track what has been sent.""" - msgs = self.messages - self.messages = [] - return msgs - - def takeCommands(self, msgs): - """Returns a list of commands parsed from the output of takeMsgs().""" - sidprefix = ':' + self.sid - commands = [] - for m in msgs: - args = m.split() - if m.startswith(sidprefix): - commands.append(args[1]) - else: - commands.append(args[0]) - return commands - - def takeHooks(self): - """Returns a list of hook arguments sent by the protocol module since - the last takeHooks() call.""" - hookmsgs = self.hookmsgs - self.hookmsgs = [] - return hookmsgs - -class FakeProto(Protocol): - """Dummy protocol module for testing purposes.""" - def handle_events(self, data): - pass - - def connect(self): - pass - - def spawnClient(self, nick, *args, **kwargs): - uid = str(randint(1, 10000000000)) - ts = int(time.time()) - self.irc.users[uid] = user = IrcUser(nick, ts, uid) - return user - - def join(self, client, channel): - self.irc.channels[channel].users.add(client) - self.irc.users[client].channels.add(channel) - -FakeProto.Class = FakeProto