fix(admin): accept /stats with bot mention
This commit is contained in:
1 parent
f1712d6db0
commit
741a27eb27
3 files changed
+32
-2
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import re
|
||||
import unittest
|
||||
|
||||
from bot import STATS_COMMAND_PATTERN
|
||||
|
||||
|
||||
class StatsCommandPatternTests(unittest.TestCase):
|
||||
def test_matches_plain_and_mentioned_forms(self):
|
||||
# В группе команду часто отправляют с явным обращением к боту.
|
||||
for text in ("/stats", "/stats@pisatel_posts_bot", "/stats all", "/stats@pisatel_posts_bot week"):
|
||||
with self.subTest(text=text):
|
||||
self.assertIsNotNone(re.match(STATS_COMMAND_PATTERN, text))
|
||||
|
||||
def test_rejects_unknown_arguments(self):
|
||||
for text in ("/stats yearly", "/stats@bot unknown", "stats", "/statsical"):
|
||||
with self.subTest(text=text):
|
||||
self.assertIsNone(re.match(STATS_COMMAND_PATTERN, text))
|
||||
|
||||
def test_period_argument_is_extractable(self):
|
||||
match = re.match(STATS_COMMAND_PATTERN, "/stats@pisatel_posts_bot month")
|
||||
self.assertIsNotNone(match)
|
||||
assert match is not None
|
||||
self.assertEqual(match.group(1), "month")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user