witai: Add __init__.py and fix tests.
ADD
zulip_bots/zulip_bots/bots/witai/__init__.py
zulip_bots/zulip_bots/bots/witai/__init__.py
MODIFY
zulip_bots/zulip_bots/bots/witai/test_witai.py
zulip_bots/zulip_bots/bots/witai/test_witai.py
@@ -23,15 +23,11 @@ class TestWitaiBot(BotTestCase):
}
def test_normal(self) -> None:
+ 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') 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('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 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') 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('wit.Wit.message', return_value=self.MOCK_WITAI_RESPONSE):
self.verify_reply('', 'Qwertyuiop!')
def mock_handle(res: Dict[str, Any]) -> Optional[str]:

witai: Add __init__.py and fix tests.