aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Den4200 <[email protected]>2020-07-06 04:08:27 +0000
committerGravatar Den4200 <[email protected]>2020-07-06 04:08:27 +0000
commit40719793f9c0d8a2c5761d3730b5920a146709c3 (patch)
treed2eff8a1e2b3a522aecf74256add8803bb7049d9 /tests
parentUpdate the docstrings to account for optional channel parameter (diff)
Add tests for cog_check and get_slowmode
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/cogs/test_slowmode.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/bot/cogs/test_slowmode.py b/tests/bot/cogs/test_slowmode.py
new file mode 100644
index 000000000..fb9f3c9ad
--- /dev/null
+++ b/tests/bot/cogs/test_slowmode.py
@@ -0,0 +1,37 @@
+import unittest
+from unittest import mock
+
+from bot.cogs.slowmode import Slowmode
+from tests.helpers import MockBot, MockContext, MockTextChannel
+
+
+class SlowmodeTests(unittest.IsolatedAsyncioTestCase):
+
+ def setUp(self) -> None:
+ self.bot = MockBot()
+ self.cog = Slowmode(self.bot)
+ self.text_channel = MockTextChannel()
+ self.ctx = MockContext(channel=self.text_channel)
+
+ async def test_get_slowmode_no_channel(self) -> None:
+ """Get slowmode without a given channel"""
+ self.text_channel.mention = '#python-general'
+ self.text_channel.slowmode_delay = 5
+
+ await self.cog.get_slowmode(self.cog, self.ctx, None)
+ self.ctx.send.assert_called_once_with("The slowmode delay for #python-general is 5 seconds.")
+
+ async def test_get_slowmode_with_channel(self) -> None:
+ """Get slowmode without a given channel"""
+ self.text_channel.mention = '#python-language'
+ self.text_channel.slowmode_delay = 2
+
+ await self.cog.get_slowmode(self.cog, self.ctx, self.text_channel)
+ self.ctx.send.assert_called_once_with("The slowmode delay for #python-language is 2 seconds.")
+
+ @mock.patch("bot.cogs.slowmode.with_role_check")
+ @mock.patch("bot.cogs.slowmode.MODERATION_ROLES", new=(1, 2, 3))
+ def test_cog_check(self, role_check):
+ """Role check is called with `MODERATION_ROLES`"""
+ self.cog.cog_check(self.ctx)
+ role_check.assert_called_once_with(self.ctx, *(1, 2, 3))