from app.homelab.evening_summary import ( _fallback_summary, _parse_llm_payload, format_evening_notice, ) def test_parse_llm_payload(): raw = '{"text": "Хороший день.", "scene_tags": "full_body, smile"}' parsed = _parse_llm_payload(raw) assert parsed is not None text, scene = parsed assert "Хороший" in text assert "smile" in scene def test_parse_llm_payload_markdown_wrapped(): raw = '```json\n{"text": "Ок", "scene_tags": "cozy"}\n```' parsed = _parse_llm_payload(raw) assert parsed is not None assert parsed[0] == "Ок" def test_fallback_summary(): ctx = { "pomodoro_sessions": 2, "has_fitness_data": True, "calories": 1800, "calorie_target": 2000, "workouts_count": 0, "completed_reminders": [], } text, scene = _fallback_summary(ctx) assert "помидоро" in text.lower() or "Помидоро" in text or "2" in text assert scene def test_format_evening_notice_with_image(): notice = format_evening_notice("Итог дня.", "/api/v1/media/generated/x.png") assert notice.startswith("💪 **Сводка дня**") assert "Итог дня." in notice assert "![day]" in notice def test_format_evening_notice_text_only(): notice = format_evening_notice("Только текст.") assert "Только текст." in notice assert "![day]" not in notice