aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bot/cogs/sync/test_cog.py
blob: efffaf53bcf023fdf6a04f5d4d972d17f53672c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import unittest
from unittest import mock

from bot.cogs import sync
from tests import helpers


class SyncExtensionTests(unittest.TestCase):
    """Tests for the sync extension."""

    @staticmethod
    def test_extension_setup():
        """The Sync cog should be added."""
        bot = helpers.MockBot()
        sync.setup(bot)
        bot.add_cog.assert_called_once()


class SyncCogTests(unittest.TestCase):
    """Tests for the Sync cog."""

    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):
        """Should instantiate syncers and run a sync for the guild."""
        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.bot.loop.create_task.assert_called_once_with(mock_sync_guild_coro)