smart tdee
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import unittest
|
||||
|
||||
from app.vision.analyze import VisionResult, format_user_message, format_user_messages, vision_debug_payloads
|
||||
|
||||
|
||||
class FormatUserMessageTests(unittest.TestCase):
|
||||
def test_parse_error_in_message(self) -> None:
|
||||
result = VisionResult(parsed={}, raw_content="not json", parse_error="bad json")
|
||||
text = format_user_message("", result)
|
||||
self.assertIn("parse_error", text)
|
||||
|
||||
def test_multiple_screenshots_numbered(self) -> None:
|
||||
results = [
|
||||
VisionResult(
|
||||
parsed={"document_type": "fitness_steps", "confidence": "high", "description": "Шаги"},
|
||||
raw_content="{}",
|
||||
),
|
||||
VisionResult(
|
||||
parsed={"document_type": "other", "confidence": "medium", "description": "Еда"},
|
||||
raw_content="{}",
|
||||
),
|
||||
]
|
||||
text = format_user_messages("сравни", results)
|
||||
self.assertIn("[Скриншот 1/2: fitness_steps", text)
|
||||
self.assertIn("[Скриншот 2/2: other", text)
|
||||
self.assertIn("Подпись: сравни", text)
|
||||
self.assertEqual(text.count("Подпись:"), 1)
|
||||
|
||||
def test_vision_debug_payloads_multi(self) -> None:
|
||||
results = [
|
||||
VisionResult(parsed={"document_type": "other"}, raw_content="{}", model="m1"),
|
||||
VisionResult(parsed={"document_type": "other"}, raw_content="{}", model="m1"),
|
||||
]
|
||||
payload = vision_debug_payloads(results)
|
||||
assert payload is not None
|
||||
self.assertEqual(payload["count"], 2)
|
||||
self.assertEqual(len(payload["images"]), 2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user