aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/cogs/test_antimalware.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/bot/cogs/test_antimalware.py b/tests/bot/cogs/test_antimalware.py
index 0bb5af943..da5cd9d11 100644
--- a/tests/bot/cogs/test_antimalware.py
+++ b/tests/bot/cogs/test_antimalware.py
@@ -1,6 +1,9 @@
import asyncio
+import logging
import unittest
-from unittest.mock import AsyncMock
+from unittest.mock import AsyncMock, Mock
+
+from discord import NotFound
from bot.cogs import antimalware
from bot.constants import Roles, URLs
@@ -72,3 +75,18 @@ class AntiMalwareCogTests(unittest.TestCase):
"It looks like you tried to attach a Python file - "
f"please use a code-pasting service such as {URLs.site_schema}{URLs.site_paste}"
))
+
+ def test_removing_deleted_message_logs(self):
+ """Removing an already deleted message logs the correct message"""
+ attachment = MockAttachment(filename="python.py")
+ self.message.attachments = [attachment]
+ self.message.delete = AsyncMock(side_effect=NotFound(response=Mock(status=""), message=""))
+
+ coroutine = self.cog.on_message(self.message)
+ logger = logging.getLogger("bot.cogs.antimalware")
+
+ with self.assertLogs(logger=logger, level="INFO") as logs:
+ asyncio.run(coroutine)
+ self.assertIn(
+ f"INFO:bot.cogs.antimalware:Tried to delete message `{self.message.id}`, but message could not be found.",
+ logs.output)