diff options
| author | 2021-03-05 07:56:19 +0530 | |
|---|---|---|
| committer | 2021-10-11 12:05:29 +0530 | |
| commit | a6c609fcc745b9cb99ec1fcfc365b1f364e6ff31 (patch) | |
| tree | e01602cfec7af97e4e7a9d391e3c804932f2b799 | |
| parent | Use str() when checking for message.content (diff) | |
Fix tests according to the changes done to incidents.py
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/moderation/incidents.py | 1 | ||||
| -rw-r--r-- | tests/bot/exts/moderation/test_incidents.py | 21 | 
2 files changed, 19 insertions, 3 deletions
| diff --git a/bot/exts/moderation/incidents.py b/bot/exts/moderation/incidents.py index 9ee1407d4..813b717a8 100644 --- a/bot/exts/moderation/incidents.py +++ b/bot/exts/moderation/incidents.py @@ -478,7 +478,6 @@ class Incidents(Cog):          """Pass `message` to `add_signals` if and only if it satisfies `is_incident`."""          if is_incident(message):              message_links = DISCORD_MESSAGE_LINK_RE.findall(str(message.content)) -            print(message_links)              if message_links:                  embeds = [] 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: | 
