aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Kieran Siek <[email protected]>2020-06-22 08:58:11 +0800
committerGravatar GitHub <[email protected]>2020-06-22 08:58:11 +0800
commit03b613110d8ab9488099def1c5960e7609308fbb (patch)
tree1773e4de764f95254c89ddf7b18c67857c6ca211
parentMerge pull request #1009 from python-discord/bug/mod/bot-2a/webhook-clyde (diff)
parentMerge branch 'master' into logging-tests (diff)
Merge pull request #950 from ks129/logging-tests
Created tests for startup logging
-rw-r--r--tests/bot/cogs/test_logging.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/bot/cogs/test_logging.py b/tests/bot/cogs/test_logging.py
new file mode 100644
index 000000000..8a18fdcd6
--- /dev/null
+++ b/tests/bot/cogs/test_logging.py
@@ -0,0 +1,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()