diff --git a/zulip_bots/zulip_bots/bots/googlesearch/test_googlesearch.py b/zulip_bots/zulip_bots/bots/googlesearch/test_googlesearch.py index e7cf711..020c7ee 100644 --- a/zulip_bots/zulip_bots/bots/googlesearch/test_googlesearch.py +++ b/zulip_bots/zulip_bots/bots/googlesearch/test_googlesearch.py @@ -1,30 +1,20 @@ #!/usr/bin/env python -from zulip_bots.test_lib import BotTestCase +from zulip_bots.test_lib import StubBotTestCase from typing import Any -class TestGoogleSearchBot(BotTestCase): +class TestGoogleSearchBot(StubBotTestCase): bot_name = 'googlesearch' # Simple query def test_normal(self: Any) -> None: with self.mock_http_conversation('test_normal'): - self.assert_bot_response({'content': 'zulip'}, {'content': 'Found Result: [Zulip](https://www.google.com/url?url=https%3A%2F%2Fzulipchat.com%2F)'}, 'send_reply') + self.verify_reply( + 'zulip', + 'Found Result: [Zulip](https://www.google.com/url?url=https%3A%2F%2Fzulipchat.com%2F)' + ) - # Help without typing anything - def test_bot_help_none(self: Any) -> None: - help_message = "To use this bot, start messages with @mentioned-bot, \ - followed by what you want to search for. If \ - found, Zulip will return the first search result \ - on Google.\ - \ - An example message that could be sent is:\ - '@mentioned-bot zulip' or \ - '@mentioned-bot how to create a chatbot'." - self.assert_bot_response({'content': ''}, {'content': help_message}, 'send_reply') - - # Help from typing 'help' def test_bot_help(self: Any) -> None: help_message = "To use this bot, start messages with @mentioned-bot, \ followed by what you want to search for. If \ @@ -34,8 +24,9 @@ class TestGoogleSearchBot(BotTestCase): An example message that could be sent is:\ '@mentioned-bot zulip' or \ '@mentioned-bot how to create a chatbot'." - self.assert_bot_response({'content': 'help'}, {'content': help_message}, 'send_reply') + self.verify_reply('', help_message) + self.verify_reply('help', help_message) def test_bot_no_results(self: Any) -> None: with self.mock_http_conversation('test_no_result'): - self.assert_bot_response({'content': 'no res'}, {'content': 'Found no results.'}, 'send_reply') + self.verify_reply('no res', 'Found no results.')