Extract get_bot_message_handler().
This commit is contained in:
parent
4ca11fdd67
commit
0a477b0736
|
@ -26,19 +26,19 @@ from types import ModuleType
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
class BotTestCaseBase(TestCase):
|
def get_bot_message_handler(bot_name):
|
||||||
"""Test class for common Bot test helper methods"""
|
# type: (str) -> Any
|
||||||
bot_name = '' # type: str
|
|
||||||
|
|
||||||
def get_bot_message_handler(self):
|
|
||||||
# type: () -> Any
|
|
||||||
# message_handler is of type 'Any', since it can contain any bot's
|
# message_handler is of type 'Any', since it can contain any bot's
|
||||||
# handler class. Eventually, we want bot's handler classes to
|
# handler class. Eventually, we want bot's handler classes to
|
||||||
# inherit from a common prototype specifying the handle_message
|
# inherit from a common prototype specifying the handle_message
|
||||||
# function.
|
# function.
|
||||||
lib_module = import_module('zulip_bots.bots.{bot}.{bot}'.format(bot=self.bot_name)) # type: Any
|
lib_module = import_module('zulip_bots.bots.{bot}.{bot}'.format(bot=bot_name)) # type: Any
|
||||||
return lib_module.handler_class()
|
return lib_module.handler_class()
|
||||||
|
|
||||||
|
class BotTestCaseBase(TestCase):
|
||||||
|
"""Test class for common Bot test helper methods"""
|
||||||
|
bot_name = '' # type: str
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
# Mocking ExternalBotHandler
|
# Mocking ExternalBotHandler
|
||||||
|
@ -51,7 +51,7 @@ class BotTestCaseBase(TestCase):
|
||||||
self.mock_bot_handler.storage = StateHandler(self.mock_client)
|
self.mock_bot_handler.storage = StateHandler(self.mock_client)
|
||||||
self.mock_bot_handler.send_message.return_value = {'id': 42}
|
self.mock_bot_handler.send_message.return_value = {'id': 42}
|
||||||
self.mock_bot_handler.send_reply.return_value = {'id': 42}
|
self.mock_bot_handler.send_reply.return_value = {'id': 42}
|
||||||
self.message_handler = self.get_bot_message_handler()
|
self.message_handler = get_bot_message_handler(self.bot_name)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
|
|
Loading…
Reference in a new issue