bots: Add 100% test coverage to define bot.
This commit is contained in:
parent
d663dd2f49
commit
277b384379
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from zulip_bots.test_lib import StubBotTestCase
|
from zulip_bots.test_lib import StubBotTestCase
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
class TestDefineBot(StubBotTestCase):
|
class TestDefineBot(StubBotTestCase):
|
||||||
bot_name = "define"
|
bot_name = "define"
|
||||||
|
@ -46,3 +47,10 @@ class TestDefineBot(StubBotTestCase):
|
||||||
# Empty messages are returned with a prompt to reply. No request is sent to the Internet.
|
# Empty messages are returned with a prompt to reply. No request is sent to the Internet.
|
||||||
bot_response = "Please enter a word to define."
|
bot_response = "Please enter a word to define."
|
||||||
self.verify_reply('', bot_response)
|
self.verify_reply('', bot_response)
|
||||||
|
|
||||||
|
def test_connection_error(self) -> None:
|
||||||
|
with patch('requests.get', side_effect=Exception), \
|
||||||
|
patch('logging.exception'):
|
||||||
|
self.verify_reply(
|
||||||
|
'aeroplane',
|
||||||
|
'**aeroplane**:\nCould not load definition.')
|
||||||
|
|
Loading…
Reference in a new issue