aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Shivansh-007 <[email protected]>2021-03-05 07:56:19 +0530
committerGravatar Shivansh-007 <[email protected]>2021-10-11 12:05:29 +0530
commita6c609fcc745b9cb99ec1fcfc365b1f364e6ff31 (patch)
treee01602cfec7af97e4e7a9d391e3c804932f2b799 /tests
parentUse str() when checking for message.content (diff)
Fix tests according to the changes done to incidents.py
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/exts/moderation/test_incidents.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/bot/exts/moderation/test_incidents.py b/tests/bot/exts/moderation/test_incidents.py
index cbf7f7bcf..3c991dacc 100644
--- a/tests/bot/exts/moderation/test_incidents.py
+++ b/tests/bot/exts/moderation/test_incidents.py
@@ -7,6 +7,7 @@ from unittest.mock import AsyncMock, MagicMock, call, patch
import aiohttp
import discord
+from async_rediscache import RedisSession
from bot.constants import Colours
from bot.exts.moderation import incidents
@@ -22,6 +23,22 @@ from tests.helpers import (
MockUser,
)
+redis_session = None
+redis_loop = asyncio.get_event_loop()
+
+
+def setUpModule(): # noqa: N802
+ """Create and connect to the fakeredis session."""
+ global redis_session
+ redis_session = RedisSession(use_fakeredis=True)
+ redis_loop.run_until_complete(redis_session.connect())
+
+
+def tearDownModule(): # noqa: N802
+ """Close the fakeredis session."""
+ if redis_session:
+ redis_loop.run_until_complete(redis_session.close())
+
class MockAsyncIterable:
"""
@@ -513,7 +530,7 @@ class TestProcessEvent(TestIncidents):
with patch("bot.exts.moderation.incidents.Incidents.make_confirmation_task", mock_task):
await self.cog_instance.process_event(
reaction=incidents.Signal.ACTIONED.value,
- incident=MockMessage(),
+ incident=MockMessage(id=123),
member=MockMember(roles=[MockRole(id=1)])
)
@@ -533,7 +550,7 @@ class TestProcessEvent(TestIncidents):
with patch("bot.exts.moderation.incidents.Incidents.make_confirmation_task", mock_task):
await self.cog_instance.process_event(
reaction=incidents.Signal.ACTIONED.value,
- incident=MockMessage(),
+ incident=MockMessage(id=123),
member=MockMember(roles=[MockRole(id=1)])
)
except asyncio.TimeoutError: