aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-05-23 10:38:41 +0300
committerGravatar ks129 <[email protected]>2020-06-11 08:59:41 +0300
commit6242fbdce8935c681fa575b1c208642fe9d2635b (patch)
tree6b588b113441aa1af59930691ab1460366f9cd56
parentJam Tests: Created base test layout (diff)
Jam Tests: Created tests for case when too small amount of members given
-rw-r--r--tests/bot/cogs/test_jams.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/bot/cogs/test_jams.py b/tests/bot/cogs/test_jams.py
index 33dee593e..3e71370c2 100644
--- a/tests/bot/cogs/test_jams.py
+++ b/tests/bot/cogs/test_jams.py
@@ -1,5 +1,7 @@
import unittest
+from unittest.mock import patch
+from bot.cogs.jams import CodeJams
from bot.constants import Roles
from tests.helpers import MockBot, MockContext, MockMember, MockRole
@@ -11,4 +13,18 @@ class JamCreateTeamTests(unittest.IsolatedAsyncioTestCase):
self.bot = MockBot()
self.admin_role = MockRole(name="Admins", id=Roles.admins)
self.command_user = MockMember([self.admin_role])
- self.context = MockContext(bot=self.bot, author=self.command_user)
+ self.ctx = MockContext(bot=self.bot, author=self.command_user)
+ self.cog = CodeJams(self.bot)
+
+ @patch("bot.cogs.jams.utils")
+ async def test_too_small_amount_of_team_members_passed(self, utils_mock):
+ """Should `ctx.send` and exit early when too small amount of members."""
+ for case in (1, 2):
+ with self.subTest(amount_of_members=case):
+ self.ctx.reset_mock()
+ utils_mock.reset_mock()
+ await self.cog.createteam(
+ self.cog, self.ctx, team_name="foo", members=(MockMember() for _ in range(case))
+ )
+ self.ctx.send.assert_awaited_once()
+ utils_mock.get.assert_not_called()