diff --git a/zulip_botserver/tests/test_server.py b/zulip_botserver/tests/test_server.py index 3ce2b42..558f201 100644 --- a/zulip_botserver/tests/test_server.py +++ b/zulip_botserver/tests/test_server.py @@ -56,10 +56,18 @@ class BotServerTests(BotServerTestCase): bots_config=bots_config, check_success=True) - def test_bot_module_not_exists(self) -> None: - self.assert_bot_server_response(available_bots=[], + def test_request_for_unkown_bot(self) -> None: + bots_config = { + 'helloworld': { + 'email': 'helloworld-bot@zulip.com', + 'key': '123456789qwertyuiop', + 'site': 'http://localhost', + }, + } + self.assert_bot_server_response(available_bots=['helloworld'], event=dict(message={'content': "test message"}, - bot_email='nonexistent-bot@zulip.com'), + bot_email='unknown-bot@zulip.com'), + bots_config=bots_config, check_success=False) @mock.patch('logging.error') diff --git a/zulip_botserver/zulip_botserver/server.py b/zulip_botserver/zulip_botserver/server.py index d192393..0c3634c 100644 --- a/zulip_botserver/zulip_botserver/server.py +++ b/zulip_botserver/zulip_botserver/server.py @@ -116,10 +116,6 @@ def handle_bot() -> Union[str, BadRequest]: lib_module = app.config.get("BOTS_LIB_MODULES", {}).get(bot) bot_handler = app.config.get("BOT_HANDLERS", {}).get(bot) message_handler = app.config.get("MESSAGE_HANDLERS", {}).get(bot) - if lib_module is None: - return BadRequest("Can't find the configuration or Bot Handler code for bot {}. " - "Make sure that the `zulip_bots` package is installed, and " - "that your flaskbotrc is set up correctly".format(bot)) message_handler.handle_message(message=event["message"], bot_handler=bot_handler) return json.dumps("")