aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bot/cogs/test_logging.py
blob: 8a18fdcd68f0658593e223f0f5f3791cde61848a (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
32
import unittest
from unittest.mock import patch

from bot import constants
from bot.cogs.logging import Logging
from tests.helpers import MockBot, MockTextChannel


class LoggingTests(unittest.IsolatedAsyncioTestCase):
    """Test cases for connected login."""

    def setUp(self):
        self.bot = MockBot()
        self.cog = Logging(self.bot)
        self.dev_log = MockTextChannel(id=1234, name="dev-log")

    @patch("bot.cogs.logging.DEBUG_MODE", False)
    async def test_debug_mode_false(self):
        """Should send connected message to dev-log."""
        self.bot.get_channel.return_value = self.dev_log

        await self.cog.startup_greeting()
        self.bot.wait_until_guild_available.assert_awaited_once_with()
        self.bot.get_channel.assert_called_once_with(constants.Channels.dev_log)
        self.dev_log.send.assert_awaited_once()

    @patch("bot.cogs.logging.DEBUG_MODE", True)
    async def test_debug_mode_true(self):
        """Should not send anything to dev-log."""
        await self.cog.startup_greeting()
        self.bot.wait_until_guild_available.assert_awaited_once_with()
        self.bot.get_channel.assert_not_called()