feat: show VK photos in calculation admin

This commit is contained in:
nyan404 committed 2026-08-16 15:56:17 +03:00
1 parent 6bbd8d4b0b
commit 20b434dbcd
6 files changed
+84 -5

No files matched your search

+10
View File
@@ -7,6 +7,7 @@ from app.belki.vk_bot import (
build_message_request,
parse_text_command,
BelkiBot,
extract_photo_attachments,
)
@@ -48,6 +49,15 @@ class VkBotTests(unittest.TestCase):
self.assertIsInstance(payload, dict)
self.assertIn("command", payload)
def test_extract_photo_attachment_keeps_largest_size_and_vk_reference(self):
photos = extract_photo_attachments({"attachments": [{"type": "photo", "photo": {
"owner_id": -10, "id": 42, "access_key": "secret",
"sizes": [{"width": 100, "height": 100, "url": "small"},
{"width": 1000, "height": 800, "url": "large"}],
}}]})
self.assertEqual(photos[0]["url"], "large")
self.assertEqual(photos[0]["attachment"], "photo-10_42_secret")
if __name__ == "__main__":
unittest.main()
+9
View File
@@ -114,6 +114,15 @@ class VkConversationTests(unittest.TestCase):
self.assertIn("вьюнок=-1", confirmation)
self.assertIn("паук=3", confirmation)
def test_queued_photo_is_saved_in_confirmed_state(self):
dialog = BelkiDialog()
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("подтверд", confirmation.lower())
self.assertEqual(dialog._states[107]["attachments"][0]["url"], "https://example.test/photo.jpg")
def test_natural_inspection_accepts_character_id_without_name(self):
inspected = inspect_bulk_text("осмотр дупло 6 1617140 без ресурсов")
self.assertEqual(inspected["fields"]["character_id"], 1617140)