diff options
| author | 2023-03-03 15:01:40 +0200 | |
|---|---|---|
| committer | 2023-03-03 15:01:40 +0200 | |
| commit | 282b6fa480e37a4a6d34c7a94622da7beab35c60 (patch) | |
| tree | cc13a3c988bb7f6db20cf1468f52f8be37008aee /tests/helpers.py | |
| parent | Merge branch 'main' into 2301-fix-voting-conditions (diff) | |
| parent | Merge pull request #2380 from python-discord/trim-help-command-error-title (diff) | |
Merge branch 'main' into 2301-fix-voting-conditions
Diffstat (limited to '')
| -rw-r--r-- | tests/helpers.py | 31 | 
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/helpers.py b/tests/helpers.py index 4b980ac21..1a71f210a 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -222,7 +222,7 @@ class MockRole(CustomMockMixin, unittest.mock.Mock, ColourMixin, HashableMixin):  # Create a Member instance to get a realistic Mock of `discord.Member` -member_data = {'user': 'lemon', 'roles': [1]} +member_data = {'user': 'lemon', 'roles': [1], 'flags': 2}  state_mock = unittest.mock.MagicMock()  member_instance = discord.Member(data=member_data, guild=guild_instance, state=state_mock) @@ -479,6 +479,25 @@ class MockContext(CustomMockMixin, unittest.mock.MagicMock):          self.invoked_from_error_handler = kwargs.get('invoked_from_error_handler', False) +class MockInteraction(CustomMockMixin, unittest.mock.MagicMock): +    """ +    A MagicMock subclass to mock Interaction objects. + +    Instances of this class will follow the specifications of `discord.Interaction` +    instances. For more information, see the `MockGuild` docstring. +    """ + +    def __init__(self, **kwargs) -> None: +        super().__init__(**kwargs) +        self.me = kwargs.get('me', MockMember()) +        self.client = kwargs.get('client', MockBot()) +        self.guild = kwargs.get('guild', MockGuild()) +        self.user = kwargs.get('user', MockMember()) +        self.channel = kwargs.get('channel', MockTextChannel()) +        self.message = kwargs.get('message', MockMessage()) +        self.invoked_from_error_handler = kwargs.get('invoked_from_error_handler', False) + +  attachment_instance = discord.Attachment(data=unittest.mock.MagicMock(id=1), state=unittest.mock.MagicMock()) @@ -530,6 +549,16 @@ class MockMessage(CustomMockMixin, unittest.mock.MagicMock):          self.channel = kwargs.get('channel', MockTextChannel()) +class MockInteractionMessage(MockMessage): +    """ +    A MagicMock subclass to mock InteractionMessage objects. + +    Instances of this class will follow the specifications of `discord.InteractionMessage` instances. For more +    information, see the `MockGuild` docstring. +    """ +    pass + +  emoji_data = {'require_colons': True, 'managed': True, 'id': 1, 'name': 'hyperlemon'}  emoji_instance = discord.Emoji(guild=MockGuild(), state=unittest.mock.MagicMock(), data=emoji_data)  |