diff --git a/tools/test-bots b/tools/test-bots index cbd3b8c..4792ce5 100755 --- a/tools/test-bots +++ b/tools/test-bots @@ -98,7 +98,7 @@ def main(): for test in tests: if isinstance(test, TestCase): # Exclude test base class from being tested. - if test.__class__.__name__ not in ['StubBotTestCase', 'BotTestCase']: + if test.__class__.__name__ != 'BotTestCase': filtered_tests.addTest(test) else: filtered_tests.addTest(filter_tests(test)) diff --git a/zulip_bots/zulip_bots/bots/chess/test_chess.py b/zulip_bots/zulip_bots/bots/chess/test_chess.py index 840e4f0..a48fb9a 100644 --- a/zulip_bots/zulip_bots/bots/chess/test_chess.py +++ b/zulip_bots/zulip_bots/bots/chess/test_chess.py @@ -1,6 +1,6 @@ -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase -class TestChessBot(StubBotTestCase): +class TestChessBot(BotTestCase): bot_name = "chess" START_RESPONSE = '''New game! The board looks like this: diff --git a/zulip_bots/zulip_bots/bots/converter/test_converter.py b/zulip_bots/zulip_bots/bots/converter/test_converter.py index afdbc15..c609c18 100755 --- a/zulip_bots/zulip_bots/bots/converter/test_converter.py +++ b/zulip_bots/zulip_bots/bots/converter/test_converter.py @@ -1,6 +1,6 @@ -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase -class TestConverterBot(StubBotTestCase): +class TestConverterBot(BotTestCase): bot_name = "converter" def test_bot(self) -> None: diff --git a/zulip_bots/zulip_bots/bots/define/test_define.py b/zulip_bots/zulip_bots/bots/define/test_define.py index 5b08826..43dd850 100755 --- a/zulip_bots/zulip_bots/bots/define/test_define.py +++ b/zulip_bots/zulip_bots/bots/define/test_define.py @@ -1,7 +1,7 @@ -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase from unittest.mock import patch -class TestDefineBot(StubBotTestCase): +class TestDefineBot(BotTestCase): bot_name = "define" def test_bot(self) -> None: diff --git a/zulip_bots/zulip_bots/bots/dialogflow/test_dialogflow.py b/zulip_bots/zulip_bots/bots/dialogflow/test_dialogflow.py index 41970e1..41fcd23 100644 --- a/zulip_bots/zulip_bots/bots/dialogflow/test_dialogflow.py +++ b/zulip_bots/zulip_bots/bots/dialogflow/test_dialogflow.py @@ -1,4 +1,4 @@ -from zulip_bots.test_lib import StubBotTestCase, read_bot_fixture_data +from zulip_bots.test_lib import BotTestCase, read_bot_fixture_data from contextlib import contextmanager @@ -36,7 +36,7 @@ def mock_dialogflow(test_name: str, bot_name: str) -> Any: mock_text_request.return_value = request yield -class TestDialogFlowBot(StubBotTestCase): +class TestDialogFlowBot(BotTestCase): bot_name = 'dialogflow' def _test(self, test_name: str, message: str, response: str) -> None: diff --git a/zulip_bots/zulip_bots/bots/encrypt/test_encrypt.py b/zulip_bots/zulip_bots/bots/encrypt/test_encrypt.py index 7453dcf..e5d6e7a 100755 --- a/zulip_bots/zulip_bots/bots/encrypt/test_encrypt.py +++ b/zulip_bots/zulip_bots/bots/encrypt/test_encrypt.py @@ -1,6 +1,6 @@ -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase -class TestEncryptBot(StubBotTestCase): +class TestEncryptBot(BotTestCase): bot_name = "encrypt" def test_bot(self) -> None: diff --git a/zulip_bots/zulip_bots/bots/followup/test_followup.py b/zulip_bots/zulip_bots/bots/followup/test_followup.py index 7f59504..349b661 100755 --- a/zulip_bots/zulip_bots/bots/followup/test_followup.py +++ b/zulip_bots/zulip_bots/bots/followup/test_followup.py @@ -1,13 +1,13 @@ from zulip_bots.test_lib import ( StubBotHandler, - StubBotTestCase, + BotTestCase, get_bot_message_handler, ) from typing import Any -class TestFollowUpBot(StubBotTestCase): +class TestFollowUpBot(BotTestCase): bot_name = "followup" def test_followup_stream(self) -> None: diff --git a/zulip_bots/zulip_bots/bots/giphy/test_giphy.py b/zulip_bots/zulip_bots/bots/giphy/test_giphy.py index 2abc20a..41dd55b 100755 --- a/zulip_bots/zulip_bots/bots/giphy/test_giphy.py +++ b/zulip_bots/zulip_bots/bots/giphy/test_giphy.py @@ -2,12 +2,12 @@ from unittest.mock import patch from requests.exceptions import HTTPError, ConnectionError from typing import Any, Union -from zulip_bots.test_lib import StubBotHandler, StubBotTestCase, get_bot_message_handler +from zulip_bots.test_lib import StubBotHandler, BotTestCase, get_bot_message_handler -class TestGiphyBot(StubBotTestCase): +class TestGiphyBot(BotTestCase): bot_name = "giphy" - # Override default function in StubBotTestCase + # Override default function in BotTestCase def test_bot_responds_to_empty_message(self) -> None: # FIXME?: Giphy does not respond to empty messages pass diff --git a/zulip_bots/zulip_bots/bots/github_detail/test_github_detail.py b/zulip_bots/zulip_bots/bots/github_detail/test_github_detail.py index cf56ad4..325d718 100755 --- a/zulip_bots/zulip_bots/bots/github_detail/test_github_detail.py +++ b/zulip_bots/zulip_bots/bots/github_detail/test_github_detail.py @@ -1,12 +1,12 @@ from zulip_bots.test_lib import ( StubBotHandler, - StubBotTestCase, + BotTestCase, get_bot_message_handler, ) from typing import Any -class TestGithubDetailBot(StubBotTestCase): +class TestGithubDetailBot(BotTestCase): bot_name = "github_detail" mock_config = {'owner': 'zulip', 'repo': 'zulip'} @@ -20,7 +20,7 @@ class TestGithubDetailBot(StubBotTestCase): self.assertIn('displays details on github issues', bot.usage()) - # Override default function in StubBotTestCase + # Override default function in BotTestCase def test_bot_responds_to_empty_message(self) -> None: with self.mock_config_info(self.mock_config): self.verify_reply('', 'Failed to find any issue or PR.') diff --git a/zulip_bots/zulip_bots/bots/google_search/test_google_search.py b/zulip_bots/zulip_bots/bots/google_search/test_google_search.py index eb531fc..4d8d79d 100644 --- a/zulip_bots/zulip_bots/bots/google_search/test_google_search.py +++ b/zulip_bots/zulip_bots/bots/google_search/test_google_search.py @@ -1,8 +1,8 @@ -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase from unittest.mock import patch -class TestGoogleSearchBot(StubBotTestCase): +class TestGoogleSearchBot(BotTestCase): bot_name = 'google_search' # Simple query diff --git a/zulip_bots/zulip_bots/bots/google_translate/test_google_translate.py b/zulip_bots/zulip_bots/bots/google_translate/test_google_translate.py index e6d928a..a2c89ad 100644 --- a/zulip_bots/zulip_bots/bots/google_translate/test_google_translate.py +++ b/zulip_bots/zulip_bots/bots/google_translate/test_google_translate.py @@ -1,7 +1,7 @@ from unittest.mock import patch from requests.exceptions import ConnectionError -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase from zulip_bots.bots.google_translate.google_translate import TranslateError help_text = ''' @@ -11,7 +11,7 @@ Please format your message like: Visit [here](https://cloud.google.com/translate/docs/languages) for all languages ''' -class TestGoogleTranslateBot(StubBotTestCase): +class TestGoogleTranslateBot(BotTestCase): bot_name = "google_translate" def _test(self, message, response, http_config_fixture, http_fixture=None): @@ -43,7 +43,7 @@ class TestGoogleTranslateBot(StubBotTestCase): 'Translate Error. Invalid API Key..', 'test_languages', 'test_403') - # Override default function in StubBotTestCase + # Override default function in BotTestCase def test_bot_responds_to_empty_message(self): self._test('', help_text, 'test_languages') diff --git a/zulip_bots/zulip_bots/bots/helloworld/test_helloworld.py b/zulip_bots/zulip_bots/bots/helloworld/test_helloworld.py index 78a563f..7ccfb9c 100755 --- a/zulip_bots/zulip_bots/bots/helloworld/test_helloworld.py +++ b/zulip_bots/zulip_bots/bots/helloworld/test_helloworld.py @@ -1,6 +1,6 @@ -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase -class TestHelpBot(StubBotTestCase): +class TestHelpBot(BotTestCase): bot_name = "helloworld" # type: str def test_bot(self) -> None: diff --git a/zulip_bots/zulip_bots/bots/help/test_help.py b/zulip_bots/zulip_bots/bots/help/test_help.py index be2adab..79d0f9c 100755 --- a/zulip_bots/zulip_bots/bots/help/test_help.py +++ b/zulip_bots/zulip_bots/bots/help/test_help.py @@ -1,8 +1,8 @@ -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase from typing import Any -class TestHelpBot(StubBotTestCase): +class TestHelpBot(BotTestCase): bot_name = "help" def test_bot(self) -> None: diff --git a/zulip_bots/zulip_bots/bots/incrementor/test_incrementor.py b/zulip_bots/zulip_bots/bots/incrementor/test_incrementor.py index a8186fd..19d0e57 100644 --- a/zulip_bots/zulip_bots/bots/incrementor/test_incrementor.py +++ b/zulip_bots/zulip_bots/bots/incrementor/test_incrementor.py @@ -3,10 +3,10 @@ import mock from zulip_bots.test_lib import ( get_bot_message_handler, StubBotHandler, - StubBotTestCase, + BotTestCase, ) -class TestIncrementorBot(StubBotTestCase): +class TestIncrementorBot(BotTestCase): bot_name = "incrementor" def test_bot(self) -> None: diff --git a/zulip_bots/zulip_bots/bots/link_shortener/test_link_shortener.py b/zulip_bots/zulip_bots/bots/link_shortener/test_link_shortener.py index 314a452..b3cdf72 100644 --- a/zulip_bots/zulip_bots/bots/link_shortener/test_link_shortener.py +++ b/zulip_bots/zulip_bots/bots/link_shortener/test_link_shortener.py @@ -1,6 +1,6 @@ -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase -class TestLinkShortenerBot(StubBotTestCase): +class TestLinkShortenerBot(BotTestCase): bot_name = "link_shortener" def _test(self, message: str, response: str) -> None: diff --git a/zulip_bots/zulip_bots/bots/tictactoe/test_tictactoe.py b/zulip_bots/zulip_bots/bots/tictactoe/test_tictactoe.py index 360e444..1efa924 100644 --- a/zulip_bots/zulip_bots/bots/tictactoe/test_tictactoe.py +++ b/zulip_bots/zulip_bots/bots/tictactoe/test_tictactoe.py @@ -1,8 +1,8 @@ -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase from mock import patch -class TestTictactoeBot(StubBotTestCase): +class TestTictactoeBot(BotTestCase): bot_name = 'tictactoe' def test_bot(self): diff --git a/zulip_bots/zulip_bots/bots/virtual_fs/test_virtual_fs.py b/zulip_bots/zulip_bots/bots/virtual_fs/test_virtual_fs.py index 3352465..ec85cd6 100755 --- a/zulip_bots/zulip_bots/bots/virtual_fs/test_virtual_fs.py +++ b/zulip_bots/zulip_bots/bots/virtual_fs/test_virtual_fs.py @@ -1,6 +1,6 @@ -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase -class TestVirtualFsBot(StubBotTestCase): +class TestVirtualFsBot(BotTestCase): bot_name = "virtual_fs" help_txt = ('foo@example.com:\n\nThis bot implements a virtual file system for a stream.\n' 'The locations of text are persisted for the lifetime of the bot\n' diff --git a/zulip_bots/zulip_bots/bots/weather/test_weather.py b/zulip_bots/zulip_bots/bots/weather/test_weather.py index 8b0ce8c..7b42bb1 100644 --- a/zulip_bots/zulip_bots/bots/weather/test_weather.py +++ b/zulip_bots/zulip_bots/bots/weather/test_weather.py @@ -1,8 +1,8 @@ -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase from typing import Optional -class TestWeatherBot(StubBotTestCase): +class TestWeatherBot(BotTestCase): bot_name = "weather" help_content = ''' @@ -23,7 +23,7 @@ class TestWeatherBot(StubBotTestCase): else: self.verify_reply(message, response) - # Override default function in StubBotTestCase + # Override default function in BotTestCase def test_bot_responds_to_empty_message(self) -> None: self._test('', self.help_content) diff --git a/zulip_bots/zulip_bots/bots/wikipedia/test_wikipedia.py b/zulip_bots/zulip_bots/bots/wikipedia/test_wikipedia.py index e0b2b44..98e96b6 100755 --- a/zulip_bots/zulip_bots/bots/wikipedia/test_wikipedia.py +++ b/zulip_bots/zulip_bots/bots/wikipedia/test_wikipedia.py @@ -1,7 +1,7 @@ -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase from zulip_bots.request_test_lib import mock_request_exception -class TestWikipediaBot(StubBotTestCase): +class TestWikipediaBot(BotTestCase): bot_name = "wikipedia" def test_bot(self) -> None: diff --git a/zulip_bots/zulip_bots/bots/xkcd/test_xkcd.py b/zulip_bots/zulip_bots/bots/xkcd/test_xkcd.py index eb3e3f0..3a8e165 100755 --- a/zulip_bots/zulip_bots/bots/xkcd/test_xkcd.py +++ b/zulip_bots/zulip_bots/bots/xkcd/test_xkcd.py @@ -1,8 +1,8 @@ import mock from mock import MagicMock, patch -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase -class TestXkcdBot(StubBotTestCase): +class TestXkcdBot(BotTestCase): bot_name = "xkcd" def test_latest_command(self) -> None: diff --git a/zulip_bots/zulip_bots/bots/yoda/test_yoda.py b/zulip_bots/zulip_bots/bots/yoda/test_yoda.py index 173a448..c516db7 100644 --- a/zulip_bots/zulip_bots/bots/yoda/test_yoda.py +++ b/zulip_bots/zulip_bots/bots/yoda/test_yoda.py @@ -1,6 +1,6 @@ -from zulip_bots.test_lib import StubBotTestCase +from zulip_bots.test_lib import BotTestCase -class TestYodaBot(StubBotTestCase): +class TestYodaBot(BotTestCase): bot_name = "yoda" help_text = ''' @@ -25,7 +25,7 @@ class TestYodaBot(StubBotTestCase): else: self.verify_reply(message, response) - # Override default function in StubBotTestCase + # Override default function in BotTestCase def test_bot_responds_to_empty_message(self) -> None: self._test('', self.help_text) diff --git a/zulip_bots/zulip_bots/bots/youtube/fixtures/test_multiple.json b/zulip_bots/zulip_bots/bots/youtube/fixtures/test_multiple.json index cc4af0d..fb61f58 100644 --- a/zulip_bots/zulip_bots/bots/youtube/fixtures/test_multiple.json +++ b/zulip_bots/zulip_bots/bots/youtube/fixtures/test_multiple.json @@ -98,7 +98,7 @@ "publishedAt": "2017-12-07T19:00:01.000Z", "channelId": "UCxwitsUVNzwS5XBSC5UQV8Q", "title": "MARVEL RISING BEGINS! | The Next Generation of Marvel Heroes (EXCLUSIVE)", - "description": "With “Marvel Rising,” the next generation of Marvel heroes has arrived. Rising 2018. --- Cast: Kathleen Khavari – Kamala Khan/Ms. Marvel Milana Vayntrub – Doreen Green/Squirrel Girl...", + "description": "With “Marvel Rising,” the next generation of Marvel heroes has arrived. Rising 2018. --- Cast: Kathleen Khavari – Kamala KhanM Marvel Milana Vayntrub – Doreen Green/Squirrel Girl...", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/6HTPCTtkWoA/default.jpg", diff --git a/zulip_bots/zulip_bots/bots/youtube/test_youtube.py b/zulip_bots/zulip_bots/bots/youtube/test_youtube.py index 16c98d0..961c1c9 100644 --- a/zulip_bots/zulip_bots/bots/youtube/test_youtube.py +++ b/zulip_bots/zulip_bots/bots/youtube/test_youtube.py @@ -1,9 +1,9 @@ from unittest.mock import patch from requests.exceptions import HTTPError, ConnectionError -from zulip_bots.test_lib import StubBotHandler, StubBotTestCase, get_bot_message_handler +from zulip_bots.test_lib import StubBotHandler, BotTestCase, get_bot_message_handler from typing import Any, Union, Dict -class TestYoutubeBot(StubBotTestCase): +class TestYoutubeBot(BotTestCase): bot_name = "youtube" normal_config = {'key': '12345678', 'number_of_results': '5', @@ -18,7 +18,7 @@ class TestYoutubeBot(StubBotTestCase): " * @mention-bot funny cats\n" \ " * @mention-bot list funny dogs" - # Override default function in StubBotTestCase + # Override default function in BotTestCase def test_bot_responds_to_empty_message(self) -> None: with self.mock_config_info(self.normal_config), \ self.mock_http_conversation('test_keyok'): diff --git a/zulip_bots/zulip_bots/test_lib.py b/zulip_bots/zulip_bots/test_lib.py index 5625b94..ae9be4d 100755 --- a/zulip_bots/zulip_bots/test_lib.py +++ b/zulip_bots/zulip_bots/test_lib.py @@ -77,13 +77,7 @@ class StubBotHandler: if len(responses) > 1: raise Exception('The bot is giving too many responses for some reason.') -class StubBotTestCase(TestCase): - ''' - The goal for this class is to eventually replace - BotTestCase for places where we may want more - fine-grained control and less heavy setup. - ''' - +class BotTestCase(TestCase): bot_name = '' def _get_handlers(self):