aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-01-28 18:31:06 -0800
committerGravatar MarkKoz <[email protected]>2020-02-12 10:07:55 -0800
commitf9e72150b5e2f4c2ae4b3968ef2d2da29fd5adbd (patch)
tree3a170f29ee387dfd8ffb7e604cd1ef6af43d38a5 /tests
parentSync tests: test Sync cog __init__ (diff)
Sync tests: instantiate a Sync cog in setUp
* Move patches to setUp
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/cogs/sync/test_cog.py24
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)