aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-01-29 17:00:55 -0800
committerGravatar MarkKoz <[email protected]>2020-02-12 10:07:55 -0800
commitf1502c6cc6c65be5b2b29066c8a2d774e73935d9 (patch)
treeb2051253518cc3c09855f9be45836decec5fd523 /tests
parentSync tests: instantiate a Sync cog in setUp (diff)
Sync tests: use mock.patch for sync_guild
This prevents persistence of changes to the cog instance; sync_guild would otherwise remain as a mock object for any subsequent tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/cogs/sync/test_cog.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/bot/cogs/sync/test_cog.py b/tests/bot/cogs/sync/test_cog.py
index 74afa2f9d..118782db3 100644
--- a/tests/bot/cogs/sync/test_cog.py
+++ b/tests/bot/cogs/sync/test_cog.py
@@ -33,7 +33,8 @@ class SyncCogTests(unittest.TestCase):
self.role_syncer_patcher.stop()
self.user_syncer_patcher.stop()
- def test_sync_cog_init(self):
+ @mock.patch.object(sync.Sync, "sync_guild")
+ def test_sync_cog_init(self, sync_guild):
"""Should instantiate syncers and run a sync for the guild."""
# Reset because a Sync cog was already instantiated in setUp.
self.RoleSyncer.reset_mock()
@@ -41,10 +42,11 @@ class SyncCogTests(unittest.TestCase):
self.bot.loop.create_task.reset_mock()
mock_sync_guild_coro = mock.MagicMock()
- sync.Sync.sync_guild = mock.MagicMock(return_value=mock_sync_guild_coro)
+ sync_guild.return_value = mock_sync_guild_coro
sync.Sync(self.bot)
self.RoleSyncer.assert_called_once_with(self.bot)
self.UserSyncer.assert_called_once_with(self.bot)
+ sync_guild.assert_called_once_with()
self.bot.loop.create_task.assert_called_once_with(mock_sync_guild_coro)