fix: require screenshots only for inspections
This commit is contained in:
1 parent
5b8f61fb96
commit
5e34b33e47
2 files changed
+21
-29
No files matched your search
+11
-8
@@ -1181,7 +1181,7 @@ class BelkiDialog:
|
|||||||
"""
|
"""
|
||||||
Возвращает вопрос для следующего незаполненного поля в форме.
|
Возвращает вопрос для следующего незаполненного поля в форме.
|
||||||
|
|
||||||
Если все поля заполнены, просит прислать скриншоты.
|
Если все поля заполнены, просит скриншот только для осмотра.
|
||||||
"""
|
"""
|
||||||
for key, prompt in self._ORDERS[state["mode"]]:
|
for key, prompt in self._ORDERS[state["mode"]]:
|
||||||
if not self._has_field(state, key):
|
if not self._has_field(state, key):
|
||||||
@@ -1214,11 +1214,14 @@ class BelkiDialog:
|
|||||||
if state["mode"] == "goal":
|
if state["mode"] == "goal":
|
||||||
state["confirm"] = True
|
state["confirm"] = True
|
||||||
return self._confirmation(state)
|
return self._confirmation(state)
|
||||||
state["awaiting_attachments"] = True
|
if state["mode"] == "inspection":
|
||||||
return (
|
state["awaiting_attachments"] = True
|
||||||
"Пришлите сюда скриншоты для этого отчёта. "
|
return (
|
||||||
"После загрузки фотографий снова откройте меню и выберите «Готово»."
|
"Пришлите один скриншот истории для подтверждения осмотра и ресурсов, "
|
||||||
)
|
"затем нажмите «Готово»."
|
||||||
|
)
|
||||||
|
state["confirm"] = True
|
||||||
|
return self._confirmation(state)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _has_field(state: dict[str, Any], key: str) -> bool:
|
def _has_field(state: dict[str, Any], key: str) -> bool:
|
||||||
@@ -1315,8 +1318,8 @@ class BelkiDialog:
|
|||||||
parsed["mode"] = "coaching"
|
parsed["mode"] = "coaching"
|
||||||
self._states[peer_id] = parsed
|
self._states[peer_id] = parsed
|
||||||
return "Данные распознаны, но не указан статус котёнка. Ответьте: самостоятельно или несамостоятельно."
|
return "Данные распознаны, но не указан статус котёнка. Ответьте: самостоятельно или несамостоятельно."
|
||||||
self._states[peer_id] = {**parsed, "awaiting_attachments": True}
|
self._states[peer_id] = {**parsed, "confirm": True}
|
||||||
return "Пришлите сюда скриншоты для этого отчёта. После загрузки фотографий снова откройте меню и выберите «Готово»."
|
return self._confirmation(self._states[peer_id])
|
||||||
if command.lower() in ("/урок", "/тренировка"):
|
if command.lower() in ("/урок", "/тренировка"):
|
||||||
state = {"mode": "training"}
|
state = {"mode": "training"}
|
||||||
self._apply_known_profile(peer_id, state)
|
self._apply_known_profile(peer_id, state)
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ class VkConversationTests(unittest.TestCase):
|
|||||||
self.assertIn("сопровождающ", dialog.handle(77, "11:20").lower())
|
self.assertIn("сопровождающ", dialog.handle(77, "11:20").lower())
|
||||||
self.assertIn("котён", dialog.handle(77, "Дикая Вишня [1604614]").lower())
|
self.assertIn("котён", dialog.handle(77, "Дикая Вишня [1604614]").lower())
|
||||||
self.assertIn("самостоятель", dialog.handle(77, "Серолап [1617140]").lower())
|
self.assertIn("самостоятель", dialog.handle(77, "Серолап [1617140]").lower())
|
||||||
self.assertIn("скриншот", dialog.handle(77, "самостоятельно").lower())
|
confirmation = dialog.handle(77, "самостоятельно")
|
||||||
confirmation = self.add_screenshot(dialog, 77)
|
|
||||||
self.assertIn("подтверд", confirmation.lower())
|
self.assertIn("подтверд", confirmation.lower())
|
||||||
report = dialog.handle(77, "да")
|
report = dialog.handle(77, "да")
|
||||||
self.assertIn("Баллы белки: 4 балла.", report)
|
self.assertIn("Баллы белки: 4 балла.", report)
|
||||||
@@ -86,7 +85,7 @@ class VkConversationTests(unittest.TestCase):
|
|||||||
for answer in ("15.08", "11:00", "12:00", "Дикая Вишня [1604614]"):
|
for answer in ("15.08", "11:00", "12:00", "Дикая Вишня [1604614]"):
|
||||||
dialog.handle(81, answer)
|
dialog.handle(81, answer)
|
||||||
response = dialog.handle(81, "Беззубик [1] самостоятельно, Малыш [2] несамостоятельно")
|
response = dialog.handle(81, "Беззубик [1] самостоятельно, Малыш [2] несамостоятельно")
|
||||||
self.assertIn("скриншот", response.lower())
|
self.assertIn("подтверд", response.lower())
|
||||||
|
|
||||||
def test_bulk_input_is_detected_and_confirmed(self):
|
def test_bulk_input_is_detected_and_confirmed(self):
|
||||||
dialog = BelkiDialog()
|
dialog = BelkiDialog()
|
||||||
@@ -94,8 +93,6 @@ class VkConversationTests(unittest.TestCase):
|
|||||||
88,
|
88,
|
||||||
"/лу 15.08 11:00 11:20 | Дикая Вишня [1604614] | Серолап [1617140] | самостоятельно",
|
"/лу 15.08 11:00 11:20 | Дикая Вишня [1604614] | Серолап [1617140] | самостоятельно",
|
||||||
)
|
)
|
||||||
self.assertIn("скриншот", confirmation.lower())
|
|
||||||
confirmation = self.add_screenshot(dialog, 88)
|
|
||||||
self.assertIn("распознал", confirmation.lower())
|
self.assertIn("распознал", confirmation.lower())
|
||||||
self.assertIn("11:00", confirmation)
|
self.assertIn("11:00", confirmation)
|
||||||
self.assertIn("подтверд", confirmation.lower())
|
self.assertIn("подтверд", confirmation.lower())
|
||||||
@@ -141,7 +138,7 @@ class VkConversationTests(unittest.TestCase):
|
|||||||
response = dialog.handle(101, "ЛУ")
|
response = dialog.handle(101, "ЛУ")
|
||||||
self.assertIn("самостоятель", response.lower())
|
self.assertIn("самостоятель", response.lower())
|
||||||
response = dialog.handle(101, "самостоятельно")
|
response = dialog.handle(101, "самостоятельно")
|
||||||
self.assertIn("скриншот", response.lower())
|
self.assertIn("подтверд", response.lower())
|
||||||
|
|
||||||
def test_natural_bulk_input_extracts_people_before_time_range(self):
|
def test_natural_bulk_input_extracts_people_before_time_range(self):
|
||||||
for text in (
|
for text in (
|
||||||
@@ -205,14 +202,12 @@ class VkConversationTests(unittest.TestCase):
|
|||||||
dialog = BelkiDialog()
|
dialog = BelkiDialog()
|
||||||
self.assertIn("сопровождающ", dialog.handle(102, "/урок").lower())
|
self.assertIn("сопровождающ", dialog.handle(102, "/урок").lower())
|
||||||
self.assertIn("котён", dialog.handle(102, "Дикая Вишня [1604614]").lower())
|
self.assertIn("котён", dialog.handle(102, "Дикая Вишня [1604614]").lower())
|
||||||
self.assertIn("скриншот", dialog.handle(102, "Серолап [1617140]").lower())
|
confirmation = dialog.handle(102, "Серолап [1617140]")
|
||||||
confirmation = self.add_screenshot(dialog, 102)
|
self.assertIn("подтверд", confirmation.lower())
|
||||||
self.assertIn("25", confirmation)
|
self.assertIn("25", confirmation)
|
||||||
self.assertIn("#урок", dialog.handle(102, "да"))
|
self.assertIn("#урок", dialog.handle(102, "да"))
|
||||||
|
|
||||||
natural = dialog.handle(103, "урок Дикая Вишня 1604614 Серолап 1617140")
|
natural = dialog.handle(103, "урок Дикая Вишня 1604614 Серолап 1617140")
|
||||||
self.assertIn("скриншот", natural.lower())
|
|
||||||
natural = self.add_screenshot(dialog, 103)
|
|
||||||
self.assertIn("25", natural)
|
self.assertIn("25", natural)
|
||||||
self.assertIn("подтверд", natural.lower())
|
self.assertIn("подтверд", natural.lower())
|
||||||
|
|
||||||
@@ -256,8 +251,7 @@ class VkConversationTests(unittest.TestCase):
|
|||||||
dialog.queue_attachments(107, [{"type": "photo", "url": "https://example.test/photo.jpg"}])
|
dialog.queue_attachments(107, [{"type": "photo", "url": "https://example.test/photo.jpg"}])
|
||||||
dialog.handle(107, "/урок")
|
dialog.handle(107, "/урок")
|
||||||
dialog.handle(107, "Белка [1]")
|
dialog.handle(107, "Белка [1]")
|
||||||
self.assertIn("скриншот", dialog.handle(107, "Котёнок [2]").lower())
|
confirmation = dialog.handle(107, "Котёнок [2]")
|
||||||
confirmation = self.add_screenshot(dialog, 107)
|
|
||||||
self.assertIn("подтверд", confirmation.lower())
|
self.assertIn("подтверд", confirmation.lower())
|
||||||
self.assertEqual(dialog._states[107]["attachments"][0]["url"], "https://example.test/photo.jpg")
|
self.assertEqual(dialog._states[107]["attachments"][0]["url"], "https://example.test/photo.jpg")
|
||||||
|
|
||||||
@@ -265,11 +259,8 @@ class VkConversationTests(unittest.TestCase):
|
|||||||
dialog = BelkiDialog()
|
dialog = BelkiDialog()
|
||||||
dialog.handle(109, "/урок")
|
dialog.handle(109, "/урок")
|
||||||
dialog.handle(109, "Белка [1]")
|
dialog.handle(109, "Белка [1]")
|
||||||
dialog.handle(109, "Котёнок [2]")
|
confirmation = dialog.handle(109, "Котёнок [2]")
|
||||||
dialog.queue_attachments(109, [{"type": "photo", "attachment": f"photo1_{index}", "url": f"https://example.test/{index}.jpg"} for index in range(6)])
|
|
||||||
confirmation = dialog.handle(109, "готово")
|
|
||||||
self.assertIn("подтверд", confirmation.lower())
|
self.assertIn("подтверд", confirmation.lower())
|
||||||
self.assertEqual(len(dialog._states[109]["attachments"]), 6)
|
|
||||||
|
|
||||||
def test_photo_is_mirrored_before_history_save(self):
|
def test_photo_is_mirrored_before_history_save(self):
|
||||||
mirrored = []
|
mirrored = []
|
||||||
@@ -283,7 +274,6 @@ class VkConversationTests(unittest.TestCase):
|
|||||||
dialog.handle(108, "/урок")
|
dialog.handle(108, "/урок")
|
||||||
dialog.handle(108, "Белка [1]")
|
dialog.handle(108, "Белка [1]")
|
||||||
dialog.handle(108, "Котёнок [2]")
|
dialog.handle(108, "Котёнок [2]")
|
||||||
self.add_screenshot(dialog, 108)
|
|
||||||
dialog.handle(108, "да")
|
dialog.handle(108, "да")
|
||||||
self.assertEqual(mirrored[0], "https://vk.example/photo.jpg")
|
self.assertEqual(mirrored[0], "https://vk.example/photo.jpg")
|
||||||
|
|
||||||
@@ -361,14 +351,13 @@ class VkConversationTests(unittest.TestCase):
|
|||||||
dialog.handle(501, "/лу")
|
dialog.handle(501, "/лу")
|
||||||
for answer in ("15.08", "11:00", "11:20", "Дикая Вишня [1604614]", "Серолап [1617140]"):
|
for answer in ("15.08", "11:00", "11:20", "Дикая Вишня [1604614]", "Серолап [1617140]"):
|
||||||
dialog.handle(501, answer)
|
dialog.handle(501, answer)
|
||||||
self.assertIn("скриншот", dialog.handle(501, "Самостоятельный").lower())
|
confirmation = dialog.handle(501, "Самостоятельный")
|
||||||
confirmation = self.add_screenshot(dialog, 501)
|
|
||||||
self.assertIn("самостоятельно", confirmation.lower())
|
self.assertIn("самостоятельно", confirmation.lower())
|
||||||
|
|
||||||
dialog.handle(502, "/лу")
|
dialog.handle(502, "/лу")
|
||||||
for answer in ("15.08", "11:00", "11:20", "Дикая Вишня [1604614]", "Серолап [1617140]"):
|
for answer in ("15.08", "11:00", "11:20", "Дикая Вишня [1604614]", "Серолап [1617140]"):
|
||||||
dialog.handle(502, answer)
|
dialog.handle(502, answer)
|
||||||
self.assertIn("скриншот", dialog.handle(502, "несам").lower())
|
self.assertIn("подтверд", dialog.handle(502, "несам").lower())
|
||||||
|
|
||||||
def test_compact_zu_command_accepts_independence_variants(self):
|
def test_compact_zu_command_accepts_independence_variants(self):
|
||||||
for value in (
|
for value in (
|
||||||
@@ -403,7 +392,7 @@ class VkConversationTests(unittest.TestCase):
|
|||||||
self.assertEqual(labels[:2], ["Сам", "Несам"])
|
self.assertEqual(labels[:2], ["Сам", "Несам"])
|
||||||
dialog.handle(503, "сам")
|
dialog.handle(503, "сам")
|
||||||
labels = [button["action"]["label"] for row in dialog.keyboard_for(503)["buttons"] for button in row]
|
labels = [button["action"]["label"] for row in dialog.keyboard_for(503)["buttons"] for button in row]
|
||||||
self.assertIn("Готово", labels)
|
self.assertEqual(labels, ["Да", "Нет"])
|
||||||
|
|
||||||
def test_quick_buttons_cover_safe_choices(self):
|
def test_quick_buttons_cover_safe_choices(self):
|
||||||
dialog = BelkiDialog()
|
dialog = BelkiDialog()
|
||||||
|
|||||||
Reference in new issue
Block a user