aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-12-31 16:05:14 -0800
committerGravatar MarkKoz <[email protected]>2020-02-12 10:07:47 -0800
commitc487d80c163682ad8e079257b6bf4bfd11743629 (patch)
treead5b1388bbcd75227274ca13452672b460ca2e98 /tests
parentSync tests: rename the role syncer test case (diff)
Sync tests: add fixture to create a guild with roles
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/cogs/sync/test_roles.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/bot/cogs/sync/test_roles.py b/tests/bot/cogs/sync/test_roles.py
index 450a192b7..5ae475b2a 100644
--- a/tests/bot/cogs/sync/test_roles.py
+++ b/tests/bot/cogs/sync/test_roles.py
@@ -1,11 +1,31 @@
import unittest
-from bot.cogs.sync.syncers import Role, get_roles_for_sync
+import discord
+
+from bot.cogs.sync.syncers import RoleSyncer
+from tests import helpers
class RoleSyncerTests(unittest.TestCase):
"""Tests constructing the roles to synchronize with the site."""
+ def setUp(self):
+ self.bot = helpers.MockBot()
+ self.syncer = RoleSyncer(self.bot)
+
+ @staticmethod
+ def get_guild(*roles):
+ """Fixture to return a guild object with the given roles."""
+ guild = helpers.MockGuild()
+ guild.roles = []
+
+ for role in roles:
+ role.colour = discord.Colour(role.colour)
+ role.permissions = discord.Permissions(role.permissions)
+ guild.roles.append(helpers.MockRole(**role))
+
+ return guild
+
def test_get_roles_for_sync_empty_return_for_equal_roles(self):
"""No roles should be synced when no diff is found."""
api_roles = {Role(id=41, name='name', colour=33, permissions=0x8, position=1)}