diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bot/cogs/sync/test_cog.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/tests/bot/cogs/sync/test_cog.py b/tests/bot/cogs/sync/test_cog.py index efffaf53b..74afa2f9d 100644 --- a/tests/bot/cogs/sync/test_cog.py +++ b/tests/bot/cogs/sync/test_cog.py @@ -22,15 +22,29 @@ class SyncCogTests(unittest.TestCase): def setUp(self): self.bot = helpers.MockBot() - @mock.patch("bot.cogs.sync.syncers.RoleSyncer", autospec=True) - @mock.patch("bot.cogs.sync.syncers.UserSyncer", autospec=True) - def test_sync_cog_init(self, mock_role, mock_sync): + self.role_syncer_patcher = mock.patch("bot.cogs.sync.syncers.RoleSyncer", autospec=True) + self.user_syncer_patcher = mock.patch("bot.cogs.sync.syncers.UserSyncer", autospec=True) + self.RoleSyncer = self.role_syncer_patcher.start() + self.UserSyncer = self.user_syncer_patcher.start() + + self.cog = sync.Sync(self.bot) + + def tearDown(self): + self.role_syncer_patcher.stop() + self.user_syncer_patcher.stop() + + def test_sync_cog_init(self): """Should instantiate syncers and run a sync for the guild.""" + # Reset because a Sync cog was already instantiated in setUp. + self.RoleSyncer.reset_mock() + self.UserSyncer.reset_mock() + 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.Sync(self.bot) - mock_role.assert_called_once_with(self.bot) - mock_sync.assert_called_once_with(self.bot) + self.RoleSyncer.assert_called_once_with(self.bot) + self.UserSyncer.assert_called_once_with(self.bot) self.bot.loop.create_task.assert_called_once_with(mock_sync_guild_coro) |