witai: Add __init__.py and fix tests.
This commit is contained in:
parent
17ad4f61ab
commit
9e5c929c86
0
zulip_bots/zulip_bots/bots/witai/__init__.py
Normal file
0
zulip_bots/zulip_bots/bots/witai/__init__.py
Normal file
|
@ -23,15 +23,11 @@ class TestWitaiBot(BotTestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_normal(self) -> None:
|
def test_normal(self) -> None:
|
||||||
with self.mock_config_info(self.MOCK_CONFIG_INFO):
|
with patch('zulip_bots.bots.witai.witai.get_handle', return_value=mock_handle):
|
||||||
get_bot_message_handler(self.bot_name).initialize(StubBotHandler())
|
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(
|
self.verify_reply(
|
||||||
'What is your favorite food?',
|
'What is your favorite food?',
|
||||||
'pizza'
|
'pizza'
|
||||||
|
@ -39,15 +35,10 @@ class TestWitaiBot(BotTestCase):
|
||||||
|
|
||||||
# This overrides the default one in `BotTestCase`.
|
# This overrides the default one in `BotTestCase`.
|
||||||
def test_bot_responds_to_empty_message(self) -> None:
|
def test_bot_responds_to_empty_message(self) -> None:
|
||||||
with self.mock_config_info(self.MOCK_CONFIG_INFO):
|
with patch('zulip_bots.bots.witai.witai.get_handle', return_value=mock_handle):
|
||||||
get_bot_message_handler(self.bot_name).initialize(StubBotHandler())
|
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:
|
with patch('wit.Wit.message', return_value=self.MOCK_WITAI_RESPONSE):
|
||||||
message.return_value = self.MOCK_WITAI_RESPONSE
|
|
||||||
|
|
||||||
with patch('zulip_bots.bots.witai.witai.get_handle') as handler:
|
|
||||||
handler.return_value = mock_handle
|
|
||||||
|
|
||||||
self.verify_reply('', 'Qwertyuiop!')
|
self.verify_reply('', 'Qwertyuiop!')
|
||||||
|
|
||||||
def mock_handle(res: Dict[str, Any]) -> Optional[str]:
|
def mock_handle(res: Dict[str, Any]) -> Optional[str]:
|
||||||
|
|
Loading…
Reference in a new issue