diff options
author | 2023-02-14 21:08:09 +0530 | |
---|---|---|
committer | 2023-02-14 21:08:09 +0530 | |
commit | 1cff5bf589a848576d3d1f4a9c1ab71633406caf (patch) | |
tree | 3d6da5f2ff009e37c9ced9d244778d66f3183d98 /tests/helpers.py | |
parent | Migrated `!tags` command to slash command `/tag` (diff) |
Update tests for `/tag` as of migration to slash commands
Diffstat (limited to 'tests/helpers.py')
-rw-r--r-- | tests/helpers.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/helpers.py b/tests/helpers.py index 4b980ac21..2d20b4d07 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -479,6 +479,26 @@ 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. + """ + # spec_set = context_instance + + 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()) |