aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-01-23 13:35:36 -0800
committerGravatar MarkKoz <[email protected]>2020-02-12 10:07:54 -0800
commit879ada59bf0a17f5cbf2590a7eb2426825b3635e (patch)
treeee718e2214343a45a411f28a07deaae460b5e191 /tests
parentSync tests: test sync redirects confirmation message to given context (diff)
Sync tests: test sync edits message even if there's an API error
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/cogs/sync/test_base.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/bot/cogs/sync/test_base.py b/tests/bot/cogs/sync/test_base.py
index a2df3e24e..314f8a70c 100644
--- a/tests/bot/cogs/sync/test_base.py
+++ b/tests/bot/cogs/sync/test_base.py
@@ -5,6 +5,7 @@ from unittest import mock
import discord
from bot import constants
+from bot.api import ResponseCodeError
from bot.cogs.sync.syncers import Syncer, _Diff
from tests import helpers
@@ -305,9 +306,16 @@ class SyncerSyncTests(unittest.TestCase):
self.assertEqual(self.syncer._get_confirmation_result.call_args[0][0], size)
def test_sync_message_edited(self):
- """The message should be edited if one was sent."""
- for message in (helpers.MockMessage(), None):
- with self.subTest(message=message):
+ """The message should be edited if one was sent, even if the sync has an API error."""
+ subtests = (
+ (None, None, False),
+ (helpers.MockMessage(), None, True),
+ (helpers.MockMessage(), ResponseCodeError(mock.MagicMock()), True),
+ )
+
+ for message, side_effect, should_edit in subtests:
+ with self.subTest(message=message, side_effect=side_effect, should_edit=should_edit):
+ self.syncer._sync.side_effect = side_effect
self.syncer._get_confirmation_result = helpers.AsyncMock(
return_value=(True, message)
)
@@ -315,7 +323,7 @@ class SyncerSyncTests(unittest.TestCase):
guild = helpers.MockGuild()
asyncio.run(self.syncer.sync(guild))
- if message is not None:
+ if should_edit:
message.edit.assert_called_once()
self.assertIn("content", message.edit.call_args[1])