aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-02-01 15:32:16 -0800
committerGravatar MarkKoz <[email protected]>2020-02-12 10:07:56 -0800
commit535095ff647277922b7d1930da8d038f15af74fd (patch)
tree3bd8491da3320abc607ddee0d9b4d900b249896c /tests
parentSync tests: test Sync cog's on_guild_role_delete listener (diff)
Tests: use objects for colour and permissions of MockRole
Instances of discord.Colour and discord.Permissions will be created by default or when ints are given as values for those attributes.
Diffstat (limited to 'tests')
-rw-r--r--tests/helpers.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index b18a27ebe..a40673bb9 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -270,9 +270,21 @@ class MockRole(CustomMockMixin, unittest.mock.Mock, ColourMixin, HashableMixin):
information, see the `MockGuild` docstring.
"""
def __init__(self, **kwargs) -> None:
- default_kwargs = {'id': next(self.discord_id), 'name': 'role', 'position': 1}
+ default_kwargs = {
+ 'id': next(self.discord_id),
+ 'name': 'role',
+ 'position': 1,
+ 'colour': discord.Colour(0xdeadbf),
+ 'permissions': discord.Permissions(),
+ }
super().__init__(spec_set=role_instance, **collections.ChainMap(kwargs, default_kwargs))
+ if isinstance(self.colour, int):
+ self.colour = discord.Colour(self.colour)
+
+ if isinstance(self.permissions, int):
+ self.permissions = discord.Permissions(self.permissions)
+
if 'mention' not in kwargs:
self.mention = f'&{self.name}'