feat: require screenshots before report confirmation
This commit is contained in:
1 parent
f6c2275af3
commit
4183d99376
3 files changed
+52
-15
No files matched your search
@@ -7,6 +7,11 @@ from app.belki.vk_bot import HELP_TEXT, BelkiDialog, inspect_bulk_text
|
||||
|
||||
|
||||
class VkConversationTests(unittest.TestCase):
|
||||
@staticmethod
|
||||
def add_screenshot(dialog, actor_id):
|
||||
dialog.queue_attachments(actor_id, [{"type": "photo", "url": "https://example.test/screenshot.jpg"}])
|
||||
return dialog.handle(actor_id, "готово")
|
||||
|
||||
def test_help_is_a_neutral_faq(self):
|
||||
self.assertIn("Беличья нора — помощь", HELP_TEXT)
|
||||
self.assertIn("Как отправить данные", HELP_TEXT)
|
||||
@@ -21,7 +26,8 @@ class VkConversationTests(unittest.TestCase):
|
||||
self.assertIn("сопровождающ", dialog.handle(77, "11:20").lower())
|
||||
self.assertIn("котён", dialog.handle(77, "Дикая Вишня [1604614]").lower())
|
||||
self.assertIn("самостоятель", dialog.handle(77, "Серолап [1617140]").lower())
|
||||
confirmation = dialog.handle(77, "самостоятельно")
|
||||
self.assertIn("скриншот", dialog.handle(77, "самостоятельно").lower())
|
||||
confirmation = self.add_screenshot(dialog, 77)
|
||||
self.assertIn("подтверд", confirmation.lower())
|
||||
report = dialog.handle(77, "да")
|
||||
self.assertIn("Баллы белки: 4 баллы.", report)
|
||||
@@ -32,6 +38,8 @@ class VkConversationTests(unittest.TestCase):
|
||||
88,
|
||||
"/лу 15.08 11:00 11:20 | Дикая Вишня [1604614] | Серолап [1617140] | самостоятельно",
|
||||
)
|
||||
self.assertIn("скриншот", confirmation.lower())
|
||||
confirmation = self.add_screenshot(dialog, 88)
|
||||
self.assertIn("распознал", confirmation.lower())
|
||||
self.assertIn("11:00", confirmation)
|
||||
self.assertIn("подтверд", confirmation.lower())
|
||||
@@ -68,17 +76,20 @@ class VkConversationTests(unittest.TestCase):
|
||||
response = dialog.handle(101, "ЛУ")
|
||||
self.assertIn("самостоятель", response.lower())
|
||||
response = dialog.handle(101, "самостоятельно")
|
||||
self.assertIn("подтверд", response.lower())
|
||||
self.assertIn("скриншот", response.lower())
|
||||
|
||||
def test_training_supports_stepwise_and_natural_bulk(self):
|
||||
dialog = BelkiDialog()
|
||||
self.assertIn("сопровождающ", dialog.handle(102, "/урок").lower())
|
||||
self.assertIn("котён", dialog.handle(102, "Дикая Вишня [1604614]").lower())
|
||||
confirmation = dialog.handle(102, "Серолап [1617140]")
|
||||
self.assertIn("скриншот", dialog.handle(102, "Серолап [1617140]").lower())
|
||||
confirmation = self.add_screenshot(dialog, 102)
|
||||
self.assertIn("25", confirmation)
|
||||
self.assertIn("#урок", dialog.handle(102, "да"))
|
||||
|
||||
natural = dialog.handle(103, "урок Дикая Вишня 1604614 Серолап 1617140")
|
||||
self.assertIn("скриншот", natural.lower())
|
||||
natural = self.add_screenshot(dialog, 103)
|
||||
self.assertIn("25", natural)
|
||||
self.assertIn("подтверд", natural.lower())
|
||||
|
||||
@@ -89,7 +100,8 @@ class VkConversationTests(unittest.TestCase):
|
||||
self.assertIn("сколько", dialog.handle(104, "дупло").lower())
|
||||
self.assertIn("персонаж", dialog.handle(104, "6").lower())
|
||||
self.assertIn("ресурс", dialog.handle(104, "1617140").lower())
|
||||
confirmation = dialog.handle(104, "без ресурсов")
|
||||
self.assertIn("скриншот", dialog.handle(104, "без ресурсов").lower())
|
||||
confirmation = self.add_screenshot(dialog, 104)
|
||||
self.assertIn("Серолап", confirmation)
|
||||
self.assertIn("подтверд", confirmation.lower())
|
||||
|
||||
@@ -101,7 +113,8 @@ class VkConversationTests(unittest.TestCase):
|
||||
response = dialog.handle(105, "1617140")
|
||||
self.assertIn("связк", response.lower())
|
||||
dialog.handle(105, "Серолап")
|
||||
confirmation = dialog.handle(105, "без ресурсов")
|
||||
dialog.handle(105, "без ресурсов")
|
||||
confirmation = self.add_screenshot(dialog, 105)
|
||||
self.assertIn("Серолап", confirmation)
|
||||
|
||||
def test_inspection_resources_use_signed_amount_before_name(self):
|
||||
@@ -110,7 +123,8 @@ class VkConversationTests(unittest.TestCase):
|
||||
dialog.handle(106, "дупло")
|
||||
dialog.handle(106, "6")
|
||||
dialog.handle(106, "Серолап [1617140]")
|
||||
confirmation = dialog.handle(106, "-1 вьюнок, + 3 паук")
|
||||
self.assertIn("скриншот", dialog.handle(106, "-1 вьюнок, + 3 паук").lower())
|
||||
confirmation = self.add_screenshot(dialog, 106)
|
||||
self.assertIn("вьюнок=-1", confirmation)
|
||||
self.assertIn("паук=3", confirmation)
|
||||
|
||||
@@ -119,7 +133,8 @@ class VkConversationTests(unittest.TestCase):
|
||||
dialog.queue_attachments(107, [{"type": "photo", "url": "https://example.test/photo.jpg"}])
|
||||
dialog.handle(107, "/урок")
|
||||
dialog.handle(107, "Белка [1]")
|
||||
confirmation = dialog.handle(107, "Котёнок [2]")
|
||||
self.assertIn("скриншот", dialog.handle(107, "Котёнок [2]").lower())
|
||||
confirmation = self.add_screenshot(dialog, 107)
|
||||
self.assertIn("подтверд", confirmation.lower())
|
||||
self.assertEqual(dialog._states[107]["attachments"][0]["url"], "https://example.test/photo.jpg")
|
||||
|
||||
@@ -135,8 +150,9 @@ class VkConversationTests(unittest.TestCase):
|
||||
dialog.handle(108, "/урок")
|
||||
dialog.handle(108, "Белка [1]")
|
||||
dialog.handle(108, "Котёнок [2]")
|
||||
self.add_screenshot(dialog, 108)
|
||||
dialog.handle(108, "да")
|
||||
self.assertEqual(mirrored, ["https://vk.example/photo.jpg"])
|
||||
self.assertEqual(mirrored[0], "https://vk.example/photo.jpg")
|
||||
|
||||
def test_natural_inspection_accepts_character_id_without_name(self):
|
||||
inspected = inspect_bulk_text("осмотр дупло 6 1617140 без ресурсов")
|
||||
@@ -170,13 +186,14 @@ class VkConversationTests(unittest.TestCase):
|
||||
dialog.handle(501, "/лу")
|
||||
for answer in ("15.08", "11:00", "11:20", "Дикая Вишня [1604614]", "Серолап [1617140]"):
|
||||
dialog.handle(501, answer)
|
||||
confirmation = dialog.handle(501, "Самостоятельный")
|
||||
self.assertIn("скриншот", dialog.handle(501, "Самостоятельный").lower())
|
||||
confirmation = self.add_screenshot(dialog, 501)
|
||||
self.assertIn("самостоятельно", confirmation.lower())
|
||||
|
||||
dialog.handle(502, "/лу")
|
||||
for answer in ("15.08", "11:00", "11:20", "Дикая Вишня [1604614]", "Серолап [1617140]"):
|
||||
dialog.handle(502, answer)
|
||||
self.assertIn("несамостоятельно", dialog.handle(502, "несам").lower())
|
||||
self.assertIn("скриншот", dialog.handle(502, "несам").lower())
|
||||
|
||||
def test_keyboard_changes_with_dialog_state(self):
|
||||
dialog = BelkiDialog()
|
||||
@@ -188,6 +205,9 @@ class VkConversationTests(unittest.TestCase):
|
||||
dialog.handle(503, answer)
|
||||
labels = [button["action"]["label"] for row in dialog.keyboard_for(503)["buttons"] for button in row]
|
||||
self.assertEqual(labels[:2], ["Сам", "Несам"])
|
||||
dialog.handle(503, "сам")
|
||||
labels = [button["action"]["label"] for row in dialog.keyboard_for(503)["buttons"] for button in row]
|
||||
self.assertIn("Готово", labels)
|
||||
|
||||
def test_quick_buttons_cover_safe_choices(self):
|
||||
dialog = BelkiDialog()
|
||||
|
||||
Reference in new issue
Block a user