aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bot/exts/moderation/test_modlog.py
blob: f2b02bd1bd1d2bac31f8253801e26e2edded017d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import unittest

import discord

from bot.exts.moderation.modlog import ModLog
from bot.utils.modlog import send_log_message
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_truncation(self):
        """Test that embed description for ModLog entry is truncated."""
        self.bot.get_channel.return_value = self.channel
        await send_log_message(
            self.bot,
            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)[:4093] + "..."
        )