diff options
author | 2020-05-18 19:17:25 +0300 | |
---|---|---|
committer | 2020-05-18 19:17:25 +0300 | |
commit | faf9737548c82cff5369ec145530f6fc86f8c0cc (patch) | |
tree | 69867129ebe733f5738624eb4a4b1e91c0d643eb | |
parent | EH Tests: Created test for all other errors (diff) |
EH Tests: Created first test for `try_silence`
-rw-r--r-- | tests/bot/cogs/test_error_handler.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/bot/cogs/test_error_handler.py b/tests/bot/cogs/test_error_handler.py index d0a5ba21b..f409cf6bc 100644 --- a/tests/bot/cogs/test_error_handler.py +++ b/tests/bot/cogs/test_error_handler.py @@ -5,6 +5,7 @@ from discord.ext.commands import errors from bot.api import ResponseCodeError from bot.cogs.error_handler import ErrorHandler +from bot.cogs.moderation.silence import Silence from tests.helpers import MockBot, MockContext @@ -159,3 +160,20 @@ class ErrorHandlerTests(unittest.IsolatedAsyncioTestCase): error = errors.DisabledCommand() # Use this just as a other error self.assertIsNone(await cog.on_command_error(self.ctx, error)) log_mock.debug.assert_called_once() + + +class TrySilenceTests(unittest.IsolatedAsyncioTestCase): + """Test for helper functions that handle `CommandNotFound` error.""" + + def setUp(self): + self.bot = MockBot() + + async def test_try_silence_context_invoked_from_error_handler(self): + """Should set `Context.invoked_from_error_handler` to `True`.""" + cog = ErrorHandler(self.bot) + ctx = MockContext(bot=self.bot) + ctx.invoked_with = "foo" + self.bot.get_command.return_value = Silence(self.bot).silence + await cog.try_silence(ctx) + self.assertTrue(hasattr(ctx, "invoked_from_error_handler")) + self.assertTrue(ctx.invoked_from_error_handler) |