diff --git a/zulip_bots/zulip_bots/bots/witai/__init__.py b/zulip_bots/zulip_bots/bots/witai/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/zulip_bots/zulip_bots/bots/witai/test_witai.py b/zulip_bots/zulip_bots/bots/witai/test_witai.py index 498dfbb..5cb8e49 100644 --- a/zulip_bots/zulip_bots/bots/witai/test_witai.py +++ b/zulip_bots/zulip_bots/bots/witai/test_witai.py @@ -23,15 +23,11 @@ class TestWitaiBot(BotTestCase): } def test_normal(self) -> None: - with self.mock_config_info(self.MOCK_CONFIG_INFO): - get_bot_message_handler(self.bot_name).initialize(StubBotHandler()) - - with patch('wit.Wit.message') as message: - message.return_value = self.MOCK_WITAI_RESPONSE - - with patch('zulip_bots.bots.witai.witai.get_handle') as handler: - handler.return_value = mock_handle + with patch('zulip_bots.bots.witai.witai.get_handle', return_value=mock_handle): + with self.mock_config_info(self.MOCK_CONFIG_INFO): + get_bot_message_handler(self.bot_name).initialize(StubBotHandler()) + with patch('wit.Wit.message', return_value=self.MOCK_WITAI_RESPONSE): self.verify_reply( 'What is your favorite food?', 'pizza' @@ -39,15 +35,10 @@ class TestWitaiBot(BotTestCase): # This overrides the default one in `BotTestCase`. def test_bot_responds_to_empty_message(self) -> None: - with self.mock_config_info(self.MOCK_CONFIG_INFO): - get_bot_message_handler(self.bot_name).initialize(StubBotHandler()) - - with patch('wit.Wit.message') as message: - message.return_value = self.MOCK_WITAI_RESPONSE - - with patch('zulip_bots.bots.witai.witai.get_handle') as handler: - handler.return_value = mock_handle - + with patch('zulip_bots.bots.witai.witai.get_handle', return_value=mock_handle): + with self.mock_config_info(self.MOCK_CONFIG_INFO): + get_bot_message_handler(self.bot_name).initialize(StubBotHandler()) + with patch('wit.Wit.message', return_value=self.MOCK_WITAI_RESPONSE): self.verify_reply('', 'Qwertyuiop!') def mock_handle(res: Dict[str, Any]) -> Optional[str]: