aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/exts/moderation/infraction/test_infractions.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/bot/exts/moderation/infraction/test_infractions.py b/tests/bot/exts/moderation/infraction/test_infractions.py
index 26ba770dc..f257bec7d 100644
--- a/tests/bot/exts/moderation/infraction/test_infractions.py
+++ b/tests/bot/exts/moderation/infraction/test_infractions.py
@@ -37,7 +37,9 @@ class TruncationTests(unittest.IsolatedAsyncioTestCase):
self.cog.mod_log.ignore = Mock()
self.ctx.guild.ban = AsyncMock()
- await self.cog.apply_ban(self.ctx, self.target, "foo bar" * 3000)
+ infraction_reason = "foo bar" * 3000
+
+ await self.cog.apply_ban(self.ctx, self.target, infraction_reason)
self.cog.apply_infraction.assert_awaited_once_with(
self.ctx, {"foo": "bar", "purge": ""}, self.target, ANY
)
@@ -46,10 +48,14 @@ class TruncationTests(unittest.IsolatedAsyncioTestCase):
await action()
self.ctx.guild.ban.assert_awaited_once_with(
self.target,
- reason=textwrap.shorten("foo bar" * 3000, 512, placeholder="..."),
+ reason=textwrap.shorten(infraction_reason, 512, placeholder="..."),
delete_message_days=0
)
+ # Assert that the reason sent to the database isn't truncated.
+ post_infraction_mock.assert_awaited_once()
+ self.assertEqual(post_infraction_mock.call_args.args[3], infraction_reason)
+
@patch("bot.exts.moderation.infraction._utils.post_infraction")
async def test_apply_kick_reason_truncation(self, post_infraction_mock):
"""Should truncate reason for `Member.kick`."""
@@ -59,14 +65,20 @@ class TruncationTests(unittest.IsolatedAsyncioTestCase):
self.cog.mod_log.ignore = Mock()
self.target.kick = AsyncMock()
- await self.cog.apply_kick(self.ctx, self.target, "foo bar" * 3000)
+ infraction_reason = "foo bar" * 3000
+
+ await self.cog.apply_kick(self.ctx, self.target, infraction_reason)
self.cog.apply_infraction.assert_awaited_once_with(
self.ctx, {"foo": "bar"}, self.target, ANY
)
action = self.cog.apply_infraction.call_args.args[-1]
await action()
- self.target.kick.assert_awaited_once_with(reason=textwrap.shorten("foo bar" * 3000, 512, placeholder="..."))
+ self.target.kick.assert_awaited_once_with(reason=textwrap.shorten(infraction_reason, 512, placeholder="..."))
+
+ # Assert that the reason sent to the database isn't truncated.
+ post_infraction_mock.assert_awaited_once()
+ self.assertEqual(post_infraction_mock.call_args.args[3], infraction_reason)
@patch("bot.exts.moderation.infraction.infractions.constants.Roles.voice_verified", new=123456)