diff options
| author | 2020-11-25 16:45:32 -0500 | |
|---|---|---|
| committer | 2020-11-25 16:45:32 -0500 | |
| commit | 3b28570818b923cb099476ad1305923dca986aea (patch) | |
| tree | 8d254074240bc089c6acc206859a6766d8af5851 /tests | |
| parent | Moved the removal of the cooldown role from `close_command` to `move_to_dormant` (diff) | |
| parent | Add Mark as a code owner of CI and Docker files (diff) | |
Merge branch 'master' of https://github.com/python-discord/bot into Stelercus/close_command
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bot/rules/test_discord_emojis.py | 29 | 
1 files changed, 25 insertions, 4 deletions
| diff --git a/tests/bot/rules/test_discord_emojis.py b/tests/bot/rules/test_discord_emojis.py index 9a72723e2..66c2d9f92 100644 --- a/tests/bot/rules/test_discord_emojis.py +++ b/tests/bot/rules/test_discord_emojis.py @@ -5,11 +5,12 @@ from tests.bot.rules import DisallowedCase, RuleTest  from tests.helpers import MockMessage  discord_emoji = "<:abcd:1234>"  # Discord emojis follow the format <:name:id> +unicode_emoji = "🧪" -def make_msg(author: str, n_emojis: int) -> MockMessage: +def make_msg(author: str, n_emojis: int, emoji: str = discord_emoji) -> MockMessage:      """Build a MockMessage instance with content containing `n_emojis` arbitrary emojis.""" -    return MockMessage(author=author, content=discord_emoji * n_emojis) +    return MockMessage(author=author, content=emoji * n_emojis)  class DiscordEmojisRuleTests(RuleTest): @@ -20,16 +21,22 @@ class DiscordEmojisRuleTests(RuleTest):          self.config = {"max": 2, "interval": 10}      async def test_allows_messages_within_limit(self): -        """Cases with a total amount of discord emojis within limit.""" +        """Cases with a total amount of discord and unicode emojis within limit."""          cases = (              [make_msg("bob", 2)],              [make_msg("alice", 1), make_msg("bob", 2), make_msg("alice", 1)], +            [make_msg("bob", 2, unicode_emoji)], +            [ +                make_msg("alice", 1, unicode_emoji), +                make_msg("bob", 2, unicode_emoji), +                make_msg("alice", 1, unicode_emoji) +            ],          )          await self.run_allowed(cases)      async def test_disallows_messages_beyond_limit(self): -        """Cases with more than the allowed amount of discord emojis.""" +        """Cases with more than the allowed amount of discord and unicode emojis."""          cases = (              DisallowedCase(                  [make_msg("bob", 3)], @@ -41,6 +48,20 @@ class DiscordEmojisRuleTests(RuleTest):                  ("alice",),                  4,              ), +            DisallowedCase( +                [make_msg("bob", 3, unicode_emoji)], +                ("bob",), +                3, +            ), +            DisallowedCase( +                [ +                    make_msg("alice", 2, unicode_emoji), +                    make_msg("bob", 2, unicode_emoji), +                    make_msg("alice", 2, unicode_emoji) +                ], +                ("alice",), +                4 +            )          )          await self.run_disallowed(cases) | 
