Add more uses of @override.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-11-13 13:36:56 -08:00
parent f78e6e653b
commit f11e960537
6 changed files with 17 additions and 1 deletions

View file

@ -2,6 +2,7 @@ from typing import Final
from unittest.mock import patch from unittest.mock import patch
from requests.exceptions import ConnectionError from requests.exceptions import ConnectionError
from typing_extensions import override
from zulip_bots.test_file_utils import get_bot_message_handler from zulip_bots.test_file_utils import get_bot_message_handler
from zulip_bots.test_lib import BotTestCase, DefaultTests, StubBotHandler from zulip_bots.test_lib import BotTestCase, DefaultTests, StubBotHandler
@ -21,6 +22,7 @@ following the syntax shown below :smile:.\n \
\n* `comment`**:** Add a comment [**NOTE:** Optional field, default is *None*]\ \n* `comment`**:** Add a comment [**NOTE:** Optional field, default is *None*]\
""" """
@override
def test_bot_responds_to_empty_message(self) -> None: def test_bot_responds_to_empty_message(self) -> None:
with self.mock_config_info(self.normal_config), self.mock_http_conversation( with self.mock_config_info(self.normal_config), self.mock_http_conversation(
"test_valid_auth_token" "test_valid_auth_token"

View file

@ -2,6 +2,7 @@ from typing import Final
from unittest.mock import patch from unittest.mock import patch
from requests.exceptions import ConnectionError from requests.exceptions import ConnectionError
from typing_extensions import override
from zulip_bots.test_lib import BotTestCase, DefaultTests from zulip_bots.test_lib import BotTestCase, DefaultTests
@ -17,6 +18,7 @@ You can send messages to any Flock user associated with your account from Zulip.
*Syntax*: **@botname to: message** where `to` is **firstName** of recipient. *Syntax*: **@botname to: message** where `to` is **firstName** of recipient.
""" """
@override
def test_bot_responds_to_empty_message(self) -> None: def test_bot_responds_to_empty_message(self) -> None:
self.verify_reply("", self.help_message) self.verify_reply("", self.help_message)

View file

@ -1,5 +1,7 @@
from typing import Dict, Final, List, Tuple from typing import Dict, Final, List, Tuple
from typing_extensions import override
from zulip_bots.bots.game_of_fifteen.game_of_fifteen import GameOfFifteenModel from zulip_bots.bots.game_of_fifteen.game_of_fifteen import GameOfFifteenModel
from zulip_bots.game_handler import BadMoveError from zulip_bots.game_handler import BadMoveError
from zulip_bots.test_lib import BotTestCase, DefaultTests from zulip_bots.test_lib import BotTestCase, DefaultTests
@ -8,6 +10,7 @@ from zulip_bots.test_lib import BotTestCase, DefaultTests
class TestGameOfFifteenBot(BotTestCase, DefaultTests): class TestGameOfFifteenBot(BotTestCase, DefaultTests):
bot_name = "game_of_fifteen" bot_name = "game_of_fifteen"
@override
def make_request_message( def make_request_message(
self, content: str, user: str = "foo@example.com", user_name: str = "foo" self, content: str, user: str = "foo@example.com", user_name: str = "foo"
) -> Dict[str, str]: ) -> Dict[str, str]:

View file

@ -1,5 +1,7 @@
from typing import Final from typing import Final
from typing_extensions import override
from zulip_bots.test_lib import BotTestCase, DefaultTests from zulip_bots.test_lib import BotTestCase, DefaultTests
@ -260,7 +262,7 @@ Jira Bot:
with self.mock_config_info(self.MOCK_CONFIG_INFO): with self.mock_config_info(self.MOCK_CONFIG_INFO):
self.verify_reply("help", self.MOCK_HELP_RESPONSE) self.verify_reply("help", self.MOCK_HELP_RESPONSE)
# This overrides the default one in `BotTestCase`. @override
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 self.mock_config_info(self.MOCK_CONFIG_INFO):
self.verify_reply("", self.MOCK_NOTHING_RESPONSE) self.verify_reply("", self.MOCK_NOTHING_RESPONSE)

View file

@ -1,5 +1,7 @@
from typing import Any, Final, List from typing import Any, Final, List
from typing_extensions import override
from zulip_bots.game_handler import GameAdapter, SamePlayerMoveError from zulip_bots.game_handler import GameAdapter, SamePlayerMoveError
from .libraries import database, game, game_data, mechanics from .libraries import database, game, game_data, mechanics
@ -76,6 +78,7 @@ class MerelsHandler(GameAdapter):
"description": "Lets you play merels against any player.", "description": "Lets you play merels against any player.",
} }
@override
def usage(self) -> str: def usage(self) -> str:
return game.get_info() return game.get_info()

View file

@ -1,6 +1,8 @@
from typing import Final from typing import Final
from unittest.mock import patch from unittest.mock import patch
from typing_extensions import override
from zulip_bots.test_file_utils import get_bot_message_handler, read_bot_fixture_data from zulip_bots.test_file_utils import get_bot_message_handler, read_bot_fixture_data
from zulip_bots.test_lib import BotTestCase, DefaultTests, StubBotHandler from zulip_bots.test_lib import BotTestCase, DefaultTests, StubBotHandler
@ -15,6 +17,7 @@ class TestTwitpostBot(BotTestCase, DefaultTests):
} }
api_response = read_bot_fixture_data("twitpost", "api_response") api_response = read_bot_fixture_data("twitpost", "api_response")
@override
def test_bot_usage(self) -> None: def test_bot_usage(self) -> None:
bot = get_bot_message_handler(self.bot_name) bot = get_bot_message_handler(self.bot_name)
bot_handler = StubBotHandler() bot_handler = StubBotHandler()
@ -24,6 +27,7 @@ class TestTwitpostBot(BotTestCase, DefaultTests):
self.assertIn("This bot posts on twitter from zulip chat itself", bot.usage()) self.assertIn("This bot posts on twitter from zulip chat itself", bot.usage())
@override
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): with self.mock_config_info(self.mock_config):
self.verify_reply("", "Please check help for usage.") self.verify_reply("", "Please check help for usage.")