aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helpers.py
diff options
context:
space:
mode:
authorGravatar Boris Muratov <[email protected]>2022-08-19 22:20:24 +0300
committerGravatar GitHub <[email protected]>2022-08-19 22:20:24 +0300
commit511671eeb05a4c0c6b600b291e4073f5358d6dcc (patch)
treeb53611b6e265fd0a85792c957a1bdd66ba417906 /tests/helpers.py
parentDuration for DM changed to Edited flag (diff)
parentMerge pull request #2260 from Dorukyum/channel.guild-nullable (diff)
Merge branch 'main' into infraction-durations
Diffstat (limited to 'tests/helpers.py')
-rw-r--r--tests/helpers.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index 17214553c..687e15b96 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -492,6 +492,28 @@ class MockAttachment(CustomMockMixin, unittest.mock.MagicMock):
spec_set = attachment_instance
+message_reference_instance = discord.MessageReference(
+ message_id=unittest.mock.MagicMock(id=1),
+ channel_id=unittest.mock.MagicMock(id=2),
+ guild_id=unittest.mock.MagicMock(id=3)
+)
+
+
+class MockMessageReference(CustomMockMixin, unittest.mock.MagicMock):
+ """
+ A MagicMock subclass to mock MessageReference objects.
+
+ Instances of this class will follow the specification of `discord.MessageReference` instances.
+ For more information, see the `MockGuild` docstring.
+ """
+ spec_set = message_reference_instance
+
+ def __init__(self, *, reference_author_is_bot: bool = False, **kwargs):
+ super().__init__(**kwargs)
+ referenced_msg_author = MockMember(name="bob", bot=reference_author_is_bot)
+ self.resolved = MockMessage(author=referenced_msg_author)
+
+
class MockMessage(CustomMockMixin, unittest.mock.MagicMock):
"""
A MagicMock subclass to mock Message objects.