aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-05-10 17:53:40 -0700
committerGravatar MarkKoz <[email protected]>2020-05-11 12:03:11 -0700
commit834bd543d1d301bb853e713560a7447dc75f1ab8 (patch)
tree97d1477b3e7edcd4316e74be0f07c2e2ec554060
parentFix autospec decorator when used with multiple attributes (diff)
Test `is_maybe_token` returns False for missing parts
In practice, this won't ever happen since the regex wouldn't match strings with missing parts. However, the function does check it so may as well test it. It's not necessarily bound to always use inputs from the regex either I suppose.
-rw-r--r--tests/bot/cogs/test_token_remover.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/bot/cogs/test_token_remover.py b/tests/bot/cogs/test_token_remover.py
index b67602eb9..9e1d96a37 100644
--- a/tests/bot/cogs/test_token_remover.py
+++ b/tests/bot/cogs/test_token_remover.py
@@ -164,6 +164,16 @@ class TokenRemoverTests(unittest.IsolatedAsyncioTestCase):
results = TOKEN_RE.findall(token)
self.assertEquals(len(results), 0)
+ @autospec(TokenRemover, "is_valid_user_id", "is_valid_timestamp")
+ def test_is_maybe_token_missing_part_returns_false(self, valid_user, valid_time):
+ """False should be returned for tokens which do not have all 3 parts."""
+ cog = TokenRemover(self.bot)
+ return_value = cog.is_maybe_token("x.y")
+
+ self.assertFalse(return_value)
+ valid_user.assert_not_called()
+ valid_time.assert_not_called()
+
def test_ignores_messages_with_invalid_tokens(self):
"""Messages with values that are invalid tokens are ignored."""
for content in ('foo.bar.baz', 'x.y.'):