bot tests: Add StubBotTestCase.mock_config_info().
We now auto-initialize bots in verify_reply() and have
a mock_config_info() helper that can override the new
StubBotHandler.get_config_info().
MODIFY
zulip_bots/zulip_bots/test_lib.py
zulip_bots/zulip_bots/test_lib.py
@@ -59,6 +59,10 @@ class StubBotHandler:
# type: (Dict[str, Any]) -> None
self.message_server.update(message)
+ def get_config_info(self, bot_name, optional=False):
+ # type: (str, bool) -> Dict[str, Any]
+ return None
+
def unique_reply(self):
# type: () -> Dict[str, Any]
responses = [
@@ -103,6 +107,9 @@ class StubBotTestCase(TestCase):
bot = get_bot_message_handler(self.bot_name)
bot_handler = StubBotHandler()
+ if hasattr(bot, 'initialize'):
+ bot.initialize(bot_handler)
+
message = dict(
sender_email='foo@example.com',
content=request,
@@ -140,6 +147,10 @@ class StubBotTestCase(TestCase):
http_data = read_bot_fixture_data(self.bot_name, test_name)
return mock_http_conversation(http_data)
+ def mock_config_info(self, config_info):
+ # type: (Dict[str, str]) -> Any
+ return patch('zulip_bots.test_lib.StubBotHandler.get_config_info', return_value=config_info)
+
def get_bot_message_handler(bot_name):
# type: (str) -> Any
# message_handler is of type 'Any', since it can contain any bot's

bot tests: Add StubBotTestCase.mock_config_info().

We now auto-initialize bots in verify_reply() and have
a mock_config_info() helper that can override the new
StubBotHandler.get_config_info().