From 517fe79e6845a4231c5bb14c78bf8cd8f5bcebb7 Mon Sep 17 00:00:00 2001 From: derAnfaenger Date: Fri, 1 Sep 2017 13:14:26 +0200 Subject: [PATCH] zulip_bot_output.py: Remove redundant get_config_info() definition. --- zulip_bots/zulip_bots/zulip_bot_output.py | 25 +++++------------------ 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/zulip_bots/zulip_bots/zulip_bot_output.py b/zulip_bots/zulip_bots/zulip_bot_output.py index 1da8185..1c108db 100644 --- a/zulip_bots/zulip_bots/zulip_bot_output.py +++ b/zulip_bots/zulip_bots/zulip_bot_output.py @@ -65,28 +65,13 @@ def main(): message = {'content': args.message, 'sender_email': 'foo_sender@zulip.com'} message_handler = lib_module.handler_class() - with patch('zulip_bots.lib.ExternalBotHandler') as mock_bot_handler: - def get_config_info(bot_name, section=None, optional=False): - # type: (str, Optional[str], Optional[bool]) -> Dict[str, Any] - conf_file_path = os.path.realpath(os.path.join( - 'zulip_bots', 'bots', bot_name, bot_name + '.conf')) - section = section or bot_name - config = configparser.ConfigParser() - try: - with open(conf_file_path) as conf: - config.readfp(conf) # type: ignore - except IOError: - if optional: - return dict() - raise - return dict(config.items(section)) - - mock_bot_handler.get_config_info = get_config_info - if hasattr(message_handler, 'initialize') and callable(message_handler.initialize): - message_handler.initialize(mock_bot_handler) - + with patch('zulip.Client') as mock_client: + mock_bot_handler = ExternalBotHandler(mock_client, bot_dir) mock_bot_handler.send_reply = MagicMock() mock_bot_handler.send_message = MagicMock() + mock_bot_handler.update_message = MagicMock() + if hasattr(message_handler, 'initialize') and callable(message_handler.initialize): + message_handler.initialize(mock_bot_handler) message_handler.handle_message( message=message, bot_handler=mock_bot_handler,