zulip_bot_output.py: Remove redundant get_config_info() definition.

This commit is contained in:
derAnfaenger 2017-09-01 13:14:26 +02:00 committed by Tim Abbott
parent 438dbac12a
commit 517fe79e68

View file

@ -65,28 +65,13 @@ def main():
message = {'content': args.message, 'sender_email': 'foo_sender@zulip.com'} message = {'content': args.message, 'sender_email': 'foo_sender@zulip.com'}
message_handler = lib_module.handler_class() message_handler = lib_module.handler_class()
with patch('zulip_bots.lib.ExternalBotHandler') as mock_bot_handler: with patch('zulip.Client') as mock_client:
def get_config_info(bot_name, section=None, optional=False): mock_bot_handler = ExternalBotHandler(mock_client, bot_dir)
# 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)
mock_bot_handler.send_reply = MagicMock() mock_bot_handler.send_reply = MagicMock()
mock_bot_handler.send_message = 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_handler.handle_message(
message=message, message=message,
bot_handler=mock_bot_handler, bot_handler=mock_bot_handler,