zulip_bots: Rename SimpleMessageServer to MockMessageServer.

Given that the purpose of this message server is solely for testing,
we rename it for clarity.
This commit is contained in:
PIG208 2021-05-25 19:54:13 +08:00 committed by Tim Abbott
parent 5f21952b77
commit d949f2024f
4 changed files with 7 additions and 7 deletions

View file

@ -19,7 +19,7 @@ class TestIncrementorBot(BotTestCase, DefaultTests):
bot.initialize(bot_handler) bot.initialize(bot_handler)
bot.handle_message(message, 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) 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') 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.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)
bot.handle_message(message, bot_handler) bot.handle_message(message, bot_handler)

View file

@ -17,7 +17,7 @@ class SimpleStorage:
def get(self, key): def get(self, key):
return self.data[key] return self.data[key]
class SimpleMessageServer: class MockMessageServer:
# This class is needed for the incrementor bot, which # This class is needed for the incrementor bot, which
# actually updates messages! # actually updates messages!
def __init__(self): def __init__(self):

View file

@ -4,7 +4,7 @@ import sys
import argparse import argparse
from zulip_bots.finder import import_module_from_source, resolve_bot_path 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__)) 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.") print("This module does not appear to have a bot handler_class specified.")
sys.exit(1) sys.exit(1)
message_server = SimpleMessageServer() message_server = MockMessageServer()
bot_handler = TerminalBotHandler(args.bot_config_file, message_server) bot_handler = TerminalBotHandler(args.bot_config_file, message_server)
if hasattr(message_handler, 'initialize') and callable(message_handler.initialize): if hasattr(message_handler, 'initialize') and callable(message_handler.initialize):
message_handler.initialize(bot_handler) message_handler.initialize(bot_handler)

View file

@ -13,7 +13,7 @@ from zulip_bots.request_test_lib import (
from zulip_bots.simple_lib import ( from zulip_bots.simple_lib import (
SimpleStorage, SimpleStorage,
SimpleMessageServer, MockMessageServer,
) )
from zulip_bots.test_file_utils import ( from zulip_bots.test_file_utils import (
@ -29,7 +29,7 @@ class StubBotHandler:
self.full_name = 'test-bot' self.full_name = 'test-bot'
self.email = 'test-bot@example.com' self.email = 'test-bot@example.com'
self.user_id = 0 self.user_id = 0
self.message_server = SimpleMessageServer() self.message_server = MockMessageServer()
self.reset_transcript() self.reset_transcript()
def reset_transcript(self) -> None: def reset_transcript(self) -> None: