From d949f2024f56104a2b92a2429b97e5039d089329 Mon Sep 17 00:00:00 2001 From: PIG208 <359101898@qq.com> Date: Tue, 25 May 2021 19:54:13 +0800 Subject: [PATCH] zulip_bots: Rename SimpleMessageServer to MockMessageServer. Given that the purpose of this message server is solely for testing, we rename it for clarity. --- zulip_bots/zulip_bots/bots/incrementor/test_incrementor.py | 4 ++-- zulip_bots/zulip_bots/simple_lib.py | 2 +- zulip_bots/zulip_bots/terminal.py | 4 ++-- zulip_bots/zulip_bots/test_lib.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/incrementor/test_incrementor.py b/zulip_bots/zulip_bots/bots/incrementor/test_incrementor.py index 9eee297..aa5f637 100644 --- a/zulip_bots/zulip_bots/bots/incrementor/test_incrementor.py +++ b/zulip_bots/zulip_bots/bots/incrementor/test_incrementor.py @@ -19,7 +19,7 @@ class TestIncrementorBot(BotTestCase, DefaultTests): bot.initialize(bot_handler) bot.handle_message(message, bot_handler) - with patch('zulip_bots.simple_lib.SimpleMessageServer.update') as m: + with patch('zulip_bots.simple_lib.MockMessageServer.update') as m: bot.handle_message(message, bot_handler) bot.handle_message(message, bot_handler) bot.handle_message(message, bot_handler) @@ -41,7 +41,7 @@ class TestIncrementorBot(BotTestCase, DefaultTests): error_msg = dict(msg='The time limit for editing this message has passed', result='error') with patch('zulip_bots.test_lib.StubBotHandler.update_message', return_value=error_msg): - with patch('zulip_bots.simple_lib.SimpleMessageServer.send') as m: + with patch('zulip_bots.simple_lib.MockMessageServer.send') as m: bot.handle_message(message, bot_handler) bot.handle_message(message, bot_handler) diff --git a/zulip_bots/zulip_bots/simple_lib.py b/zulip_bots/zulip_bots/simple_lib.py index 1a72464..34e56bd 100644 --- a/zulip_bots/zulip_bots/simple_lib.py +++ b/zulip_bots/zulip_bots/simple_lib.py @@ -17,7 +17,7 @@ class SimpleStorage: def get(self, key): return self.data[key] -class SimpleMessageServer: +class MockMessageServer: # This class is needed for the incrementor bot, which # actually updates messages! def __init__(self): diff --git a/zulip_bots/zulip_bots/terminal.py b/zulip_bots/zulip_bots/terminal.py index 6c3ed94..abc8be4 100644 --- a/zulip_bots/zulip_bots/terminal.py +++ b/zulip_bots/zulip_bots/terminal.py @@ -4,7 +4,7 @@ import sys import argparse from zulip_bots.finder import import_module_from_source, resolve_bot_path -from zulip_bots.simple_lib import SimpleMessageServer, TerminalBotHandler +from zulip_bots.simple_lib import MockMessageServer, TerminalBotHandler current_dir = os.path.dirname(os.path.abspath(__file__)) @@ -49,7 +49,7 @@ def main(): print("This module does not appear to have a bot handler_class specified.") sys.exit(1) - message_server = SimpleMessageServer() + message_server = MockMessageServer() bot_handler = TerminalBotHandler(args.bot_config_file, message_server) if hasattr(message_handler, 'initialize') and callable(message_handler.initialize): message_handler.initialize(bot_handler) diff --git a/zulip_bots/zulip_bots/test_lib.py b/zulip_bots/zulip_bots/test_lib.py index 395a5c6..53e37cc 100755 --- a/zulip_bots/zulip_bots/test_lib.py +++ b/zulip_bots/zulip_bots/test_lib.py @@ -13,7 +13,7 @@ from zulip_bots.request_test_lib import ( from zulip_bots.simple_lib import ( SimpleStorage, - SimpleMessageServer, + MockMessageServer, ) from zulip_bots.test_file_utils import ( @@ -29,7 +29,7 @@ class StubBotHandler: self.full_name = 'test-bot' self.email = 'test-bot@example.com' self.user_id = 0 - self.message_server = SimpleMessageServer() + self.message_server = MockMessageServer() self.reset_transcript() def reset_transcript(self) -> None: