Improve test coverage for Mention bot.

This commit is contained in:
Viraat Chandra 2018-01-06 20:56:21 +05:30 committed by showell
parent bffb8d0e16
commit fd97ffce77

View file

@ -1,6 +1,7 @@
from zulip_bots.bots.mention.mention import MentionHandler from zulip_bots.bots.mention.mention import MentionHandler
from unittest.mock import patch from unittest.mock import patch
from zulip_bots.test_lib import BotTestCase from zulip_bots.test_lib import BotTestCase
from zulip_bots.test_lib import StubBotHandler
class TestMentionBot(BotTestCase): class TestMentionBot(BotTestCase):
bot_name = "mention" bot_name = "mention"
@ -43,3 +44,10 @@ class TestMentionBot(BotTestCase):
bot_response = bot_test_instance.get_mentions('TEST')[0] bot_response = bot_test_instance.get_mentions('TEST')[0]
self.assertEqual(bot_response['title'], 'TEST') self.assertEqual(bot_response['title'], 'TEST')
self.assertEqual(bot_response['original_url'], 'TEST') self.assertEqual(bot_response['original_url'], 'TEST')
def test_exception_when_api_key_is_invalid(self) -> None:
bot_test_instance = MentionHandler()
with self.mock_config_info({'access_token': 'TEST'}):
with self.assertRaises(StubBotHandler.BotQuitException):
bot_test_instance.initialize(StubBotHandler())