aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2021-07-09 03:32:51 +0300
committerGravatar Hassan Abouelela <[email protected]>2021-07-09 03:32:51 +0300
commit5bbd29c8957c320ef94beacd191239032eb959ec (patch)
tree93243b0ecaa8750a5cfd19580b70b361c93ff424 /tests
parentPrevents Blocking In Ping Command (diff)
Properly Handle Fuzzy Matching Help
Fixes a bug where calling help with an invalid command would crash out during fuzzy matching. Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/exts/info/test_help.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/bot/exts/info/test_help.py b/tests/bot/exts/info/test_help.py
new file mode 100644
index 000000000..604c69671
--- /dev/null
+++ b/tests/bot/exts/info/test_help.py
@@ -0,0 +1,23 @@
+import unittest
+
+import rapidfuzz
+
+from bot.exts.info import help
+from tests.helpers import MockBot, MockContext, autospec
+
+
+class HelpCogTests(unittest.IsolatedAsyncioTestCase):
+ def setUp(self) -> None:
+ """Attach an instance of the cog to the class for tests."""
+ self.bot = MockBot()
+ self.cog = help.Help(self.bot)
+ self.ctx = MockContext(bot=self.bot)
+ self.bot.help_command.context = self.ctx
+
+ @autospec(help.CustomHelpCommand, "get_all_help_choices", return_value={"help"}, pass_mocks=False)
+ async def test_help_fuzzy_matching(self):
+ """Test fuzzy matching of commands when called from help."""
+ result = await self.bot.help_command.command_not_found("holp")
+
+ match = {"help": rapidfuzz.fuzz.ratio("help", "holp")}
+ self.assertEqual(match, result.possible_matches)