aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar ks123 <[email protected]>2020-03-05 08:43:18 +0200
committerGravatar ks123 <[email protected]>2020-03-05 08:43:18 +0200
commit30e090be63c96b5844087c979a37a321ccd170df (patch)
tree96c3e898caaaa9430d7bee462a48a0da6f18f9ad /tests
parent(Moderation Utils Tests): `send_private_embed` moved exception creating from ... (diff)
(Moderation Utils Tests): Moved `has_active_infraction` tests to one test.
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/cogs/moderation/test_utils.py57
1 files changed, 35 insertions, 22 deletions
diff --git a/tests/bot/cogs/moderation/test_utils.py b/tests/bot/cogs/moderation/test_utils.py
index 2a07cdc6b..18794136c 100644
--- a/tests/bot/cogs/moderation/test_utils.py
+++ b/tests/bot/cogs/moderation/test_utils.py
@@ -39,28 +39,41 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):
self.ctx = MockContext(bot=self.bot, author=self.member)
self.bot.api_client.get = AsyncMock()
- async def test_user_has_active_infraction_true(self):
- """Test does `has_active_infraction` return that user have active infraction."""
- self.bot.api_client.get.return_value = [{
- "id": 1,
- "inserted_at": "2018-11-22T07:24:06.132307Z",
- "expires_at": "5018-11-20T15:52:00Z",
- "active": True,
- "user": 1234,
- "actor": 1234,
- "type": "ban",
- "reason": "Test",
- "hidden": False
- }]
- self.assertTrue(await has_active_infraction(self.ctx, self.member, "ban"), "User should have active infraction")
-
- async def test_user_has_active_infraction_false(self):
- """Test does `has_active_infraction` return that user don't have active infractions."""
- self.bot.api_client.get.return_value = []
- self.assertFalse(
- await has_active_infraction(self.ctx, self.member, "ban"),
- "User shouldn't have active infraction"
- )
+ async def test_user_has_active_infraction(self):
+ """Test does `has_active_infraction` return correct value."""
+ test_cases = [
+ {
+ "args": (self.ctx, self.member, "ban"),
+ "get_return_value": [],
+ "expected_output": False
+ },
+ {
+ "args": (self.ctx, self.member, "ban"),
+ "get_return_value": [{
+ "id": 1,
+ "inserted_at": "2018-11-22T07:24:06.132307Z",
+ "expires_at": "5018-11-20T15:52:00Z",
+ "active": True,
+ "user": 1234,
+ "actor": 1234,
+ "type": "ban",
+ "reason": "Test",
+ "hidden": False
+ }],
+ "expected_output": True
+ }
+ ]
+
+ for case in test_cases:
+ args = case["args"]
+ return_value = case["get_return_value"]
+ expected = case["expected_output"]
+
+ with self.subTest(args=args, return_value=return_value, expected=expected):
+ self.bot.api_client.get.return_value = return_value
+
+ result = await has_active_infraction(*args)
+ self.assertEqual(result, expected)
async def test_notify_infraction(self):
"""Test does `notify_infraction` create correct embed."""