aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar ks123 <[email protected]>2020-03-03 17:29:20 +0200
committerGravatar ks123 <[email protected]>2020-03-03 17:29:20 +0200
commitfa6a0ae59958ce143f6a7acfbd41e477e940fa84 (patch)
tree7b6a4520c9e22eaa9dffc2ae258ddea4330e15f9 /tests
parent(Moderation Utils Tests): Added imports, modified tests class instance and cr... (diff)
(Moderation Utils Tests): Created tests for `has_active_infraction` function
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/cogs/moderation/test_utils.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/bot/cogs/moderation/test_utils.py b/tests/bot/cogs/moderation/test_utils.py
index 7d47715d4..d25fbfcb5 100644
--- a/tests/bot/cogs/moderation/test_utils.py
+++ b/tests/bot/cogs/moderation/test_utils.py
@@ -1,6 +1,7 @@
import unittest
from unittest.mock import AsyncMock
+from bot.cogs.moderation.utils import has_active_infraction
from tests.helpers import MockBot, MockContext, MockMember
@@ -12,3 +13,26 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):
self.member = MockMember(id=1234)
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"
+ )