diff options
author | 2020-04-16 11:30:09 +0300 | |
---|---|---|
committer | 2020-04-16 11:30:09 +0300 | |
commit | 216953044a870f2440fe44fcd2f9ca3ee7cf37e9 (patch) | |
tree | 2e6af5bd6fc1073cf1b38e58246e005e123133cc | |
parent | (Infraction Tests): Created reason shortening tests for ban and kick. (diff) |
(ModLog Tests): Created reason shortening tests for `send_log_message`.
-rw-r--r-- | tests/bot/cogs/moderation/test_modlog.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/bot/cogs/moderation/test_modlog.py b/tests/bot/cogs/moderation/test_modlog.py new file mode 100644 index 000000000..46e01d2ea --- /dev/null +++ b/tests/bot/cogs/moderation/test_modlog.py @@ -0,0 +1,29 @@ +import unittest + +import discord + +from bot.cogs.moderation.modlog import ModLog +from tests.helpers import MockBot, MockTextChannel + + +class ModLogTests(unittest.IsolatedAsyncioTestCase): + """Tests for moderation logs.""" + + def setUp(self): + self.bot = MockBot() + self.cog = ModLog(self.bot) + self.channel = MockTextChannel() + + async def test_log_entry_description_shortening(self): + """Should truncate embed description for ModLog entry.""" + self.bot.get_channel.return_value = self.channel + await self.cog.send_log_message( + icon_url="foo", + colour=discord.Colour.blue(), + title="bar", + text="foo bar" * 3000 + ) + embed = self.channel.send.call_args[1]["embed"] + self.assertEqual( + embed.description, ("foo bar" * 3000)[:2046] + "..." + ) |