Parser fix
This commit is contained in:
1 parent
604de30345
commit
d58a3c7e93
2 files changed
+14
-2
No files matched your search
@@ -47,6 +47,8 @@ class VkError(RuntimeError):
|
||||
|
||||
|
||||
def _person(value: str) -> tuple[str, int]:
|
||||
# Users often copy the example sentence together with its final period.
|
||||
value = value.strip().rstrip(".!?").strip()
|
||||
match = _PERSON_RE.fullmatch(value)
|
||||
if not match:
|
||||
raise ValueError("Укажите имя и ID в формате Имя [12345]")
|
||||
|
||||
@@ -13,8 +13,8 @@ class VkConversationTests(unittest.TestCase):
|
||||
return dialog.handle(actor_id, "готово")
|
||||
|
||||
def test_help_is_a_neutral_faq(self):
|
||||
self.assertIn("Беличья нора — помощь", HELP_TEXT)
|
||||
self.assertIn("Как отправить данные", HELP_TEXT)
|
||||
self.assertIn("Беличья нора", HELP_TEXT)
|
||||
self.assertIn("Два способа ввести данные", HELP_TEXT)
|
||||
self.assertIn("/отмена", HELP_TEXT)
|
||||
self.assertNotIn("Для детей", HELP_TEXT)
|
||||
|
||||
@@ -41,6 +41,16 @@ class VkConversationTests(unittest.TestCase):
|
||||
self.assertIn("самостоятель", response.lower())
|
||||
self.assertEqual(dialog._states[78]["extra_kittens"], [("Малыш", 123456, "самостоятельно")])
|
||||
|
||||
def test_comma_separated_example_accepts_trailing_period(self):
|
||||
dialog = BelkiDialog()
|
||||
dialog.handle(79, "/лу")
|
||||
for answer in ("15.08", "11:00", "16:41", "Дикая Вишня [1604614]"):
|
||||
dialog.handle(79, answer)
|
||||
response = dialog.handle(79, "Беззубик [1566767], Малыш [123456].")
|
||||
self.assertIn("самостоятель", response.lower())
|
||||
self.assertEqual(dialog._states[79]["kitten_id"], 1566767)
|
||||
self.assertEqual(dialog._states[79]["extra_kittens"][0][1], 123456)
|
||||
|
||||
def test_bulk_input_is_detected_and_confirmed(self):
|
||||
dialog = BelkiDialog()
|
||||
confirmation = dialog.handle(
|
||||
|
||||
Reference in new issue
Block a user