diff options
| author | 2020-05-30 09:34:39 +0300 | |
|---|---|---|
| committer | 2020-05-30 09:34:39 +0300 | |
| commit | 96b026198a4ca2074f4fd7ea68e8a09acd5b38e4 (patch) | |
| tree | 2dfaef7a307a13cf2439ffb821a72f590589d446 /tests | |
| parent | Infr Tests: Make `get_active_infraction` return `None` (diff) | |
Simplify infraction reason truncation tests
Diffstat (limited to '')
| -rw-r--r-- | tests/bot/cogs/moderation/test_infractions.py | 20 | 
1 files changed, 7 insertions, 13 deletions
diff --git a/tests/bot/cogs/moderation/test_infractions.py b/tests/bot/cogs/moderation/test_infractions.py index 5548d9f68..ad3c95958 100644 --- a/tests/bot/cogs/moderation/test_infractions.py +++ b/tests/bot/cogs/moderation/test_infractions.py @@ -27,15 +27,14 @@ class TruncationTests(unittest.IsolatedAsyncioTestCase):          self.cog.apply_infraction = AsyncMock()          self.bot.get_cog.return_value = AsyncMock()          self.cog.mod_log.ignore = Mock() +        self.ctx.guild.ban = Mock()          await self.cog.apply_ban(self.ctx, self.target, "foo bar" * 3000) -        ban = self.cog.apply_infraction.call_args[0][3] -        self.assertEqual( -            ban.cr_frame.f_locals["kwargs"]["reason"], -            textwrap.shorten("foo bar" * 3000, 512, placeholder="...") +        self.ctx.guild.ban.assert_called_once_with( +            self.target, +            reason=textwrap.shorten("foo bar" * 3000, 512, placeholder="..."), +            delete_message_days=0          ) -        # Await ban to avoid not awaited coroutine warning -        await ban      @patch("bot.cogs.moderation.utils.post_infraction")      async def test_apply_kick_reason_truncation(self, post_infraction_mock): @@ -44,12 +43,7 @@ class TruncationTests(unittest.IsolatedAsyncioTestCase):          self.cog.apply_infraction = AsyncMock()          self.cog.mod_log.ignore = Mock() +        self.target.kick = Mock()          await self.cog.apply_kick(self.ctx, self.target, "foo bar" * 3000) -        kick = self.cog.apply_infraction.call_args[0][3] -        self.assertEqual( -            kick.cr_frame.f_locals["kwargs"]["reason"], -            textwrap.shorten("foo bar" * 3000, 512, placeholder="...") -        ) -        # Await kick to avoid not awaited coroutine warning -        await kick +        self.target.kick.assert_called_once_with(reason=textwrap.shorten("foo bar" * 3000, 512, placeholder="..."))  |