witai: Add __init__.py and fix tests.

This commit is contained in:
neiljp (Neil Pilgrim) 2018-05-26 12:35:03 -07:00
parent 17ad4f61ab
commit 9e5c929c86
2 changed files with 8 additions and 17 deletions

View file

@ -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]: