bots: Require bots_details in ExternalBotHandler.

This parameter was defaulting to a dictionary, which is
a classic Python pitfall.
This commit is contained in:
Steve Howell 2017-11-27 12:51:02 -08:00 committed by showell
parent ef30261858
commit 8a15452525
3 changed files with 3 additions and 3 deletions

View file

@ -83,7 +83,7 @@ class StateHandler(object):
return key in self.state_ return key in self.state_
class ExternalBotHandler(object): class ExternalBotHandler(object):
def __init__(self, client, root_dir, bot_details={}): def __init__(self, client, root_dir, bot_details):
# type: (Client, str, Dict[str, Any]) -> None # type: (Client, str, Dict[str, Any]) -> None
# Only expose a subset of our Client's functionality # Only expose a subset of our Client's functionality
try: try:

View file

@ -44,7 +44,7 @@ class BotTestCaseBase(TestCase):
# Mocking ExternalBotHandler # Mocking ExternalBotHandler
self.patcher = patch('zulip_bots.lib.ExternalBotHandler', autospec=True) self.patcher = patch('zulip_bots.lib.ExternalBotHandler', autospec=True)
self.MockClass = self.patcher.start() self.MockClass = self.patcher.start()
self.mock_bot_handler = self.MockClass(None, None) self.mock_bot_handler = self.MockClass(None, None, None)
self.mock_client = MagicMock() self.mock_client = MagicMock()
self.mock_client.get_storage.return_value = {'result': 'success', 'state': {}} self.mock_client.get_storage.return_value = {'result': 'success', 'state': {}}
self.mock_client.update_storage.return_value = {'result': 'success'} self.mock_client.update_storage.return_value = {'result': 'success'}

View file

@ -54,7 +54,7 @@ def load_bot_handlers():
try: try:
bot_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), bot_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'bots', bot) 'bots', bot)
bot_handlers[bot] = ExternalBotHandler(client, bot_dir) bot_handlers[bot] = ExternalBotHandler(client, bot_dir, bot_details={})
except SystemExit: except SystemExit:
return BadRequest("Cannot fetch user profile for bot {}, make sure you have set up the flaskbotrc " return BadRequest("Cannot fetch user profile for bot {}, make sure you have set up the flaskbotrc "
"file correctly.".format(bot)) "file correctly.".format(bot))