aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-01-10 11:47:41 -0800
committerGravatar MarkKoz <[email protected]>2020-02-12 10:07:52 -0800
commit9a73feb93a7680211e597f0cc9d09b06ebc84335 (patch)
treeba3d78831f513992e5e9f25d551b005c7c0246a0
parentSync tests: create a test suite for confirmation tests (diff)
Sync tests: test _reaction_check for valid emoji and authors
Should return True if authors are identical or are a bot and a core dev, respectively. * Create a mock core dev role in the setup fixture * Create a fixture to create a mock message and reaction from an emoji
-rw-r--r--tests/bot/cogs/sync/test_base.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/bot/cogs/sync/test_base.py b/tests/bot/cogs/sync/test_base.py
index ca344c865..f722a83e8 100644
--- a/tests/bot/cogs/sync/test_base.py
+++ b/tests/bot/cogs/sync/test_base.py
@@ -130,3 +130,30 @@ class SyncerConfirmationTests(unittest.TestCase):
def setUp(self):
self.bot = helpers.MockBot()
self.syncer = TestSyncer(self.bot)
+ self.core_dev_role = helpers.MockRole(id=constants.Roles.core_developer)
+
+ @staticmethod
+ def get_message_reaction(emoji):
+ """Fixture to return a mock message an reaction from the given `emoji`."""
+ message = helpers.MockMessage()
+ reaction = helpers.MockReaction(emoji=emoji, message=message)
+
+ return message, reaction
+
+ def test_reaction_check_for_valid_emoji_and_authors(self):
+ """Should return True if authors are identical or are a bot and a core dev, respectively."""
+ user_subtests = (
+ (helpers.MockMember(id=77), helpers.MockMember(id=77)),
+ (
+ helpers.MockMember(id=77, bot=True),
+ helpers.MockMember(id=43, roles=[self.core_dev_role]),
+ )
+ )
+
+ for emoji in self.syncer._REACTION_EMOJIS:
+ for author, user in user_subtests:
+ with self.subTest(author=author, user=user, emoji=emoji):
+ message, reaction = self.get_message_reaction(emoji)
+ ret_val = self.syncer._reaction_check(author, message, reaction, user)
+
+ self.assertTrue(ret_val)