aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-01-05 10:44:31 -0800
committerGravatar MarkKoz <[email protected]>2020-02-12 10:07:51 -0800
commit6f116956395fa1b48233a3014d215a3704b929ed (patch)
tree40aa3a0b9edbccbae6753aa6857ccdd855048ccc /tests
parentSync tests: test _send_prompt fetches channel on a cache miss (diff)
Sync tests: test _send_prompt returns None if channel fetch fails
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/cogs/sync/test_base.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/bot/cogs/sync/test_base.py b/tests/bot/cogs/sync/test_base.py
index c18fa5fbb..8eecea53f 100644
--- a/tests/bot/cogs/sync/test_base.py
+++ b/tests/bot/cogs/sync/test_base.py
@@ -1,5 +1,8 @@
import asyncio
import unittest
+from unittest import mock
+
+import discord
from bot.cogs.sync.syncers import Syncer
from bot import constants
@@ -54,3 +57,12 @@ class SyncerBaseTests(unittest.TestCase):
asyncio.run(self.syncer._send_prompt())
self.bot.fetch_channel.assert_called_once_with(constants.Channels.devcore)
+
+ def test_send_prompt_returns_None_if_channel_fetch_fails(self):
+ """None should be returned if there's an HTTPException when fetching the channel."""
+ self.bot.get_channel.return_value = None
+ self.bot.fetch_channel.side_effect = discord.HTTPException(mock.MagicMock(), "test error!")
+
+ ret_val = asyncio.run(self.syncer._send_prompt())
+
+ self.assertIsNone(ret_val)