refs #732: polish HMM report title and response

This commit is contained in:
devmrko
2026-08-10 16:06:17 +09:00
parent b13b913939
commit 66fcb5d149
6 changed files with 247 additions and 5 deletions

View File

@@ -1,8 +1,10 @@
from __future__ import annotations
import ast
import html
import json
from pathlib import Path
import re
import tempfile
from typing import Any, Mapping
import unittest
@@ -174,6 +176,41 @@ class DemoScenarioConfigTest(unittest.TestCase):
self.assertEqual(len(rows), 2)
self.assertEqual(rows[0]["CARRIER_CODE"], "C901")
def test_hmm_report_title_and_answer_follow_presentation_contract(self) -> None:
source = (Path(__file__).parents[1] / "app.py").read_text(encoding="utf-8")
tree = ast.parse(source)
helper = next(
node
for node in tree.body
if isinstance(node, ast.FunctionDef)
and node.name == "_clean_presentation_title"
)
namespace: dict[str, Any] = {
"Any": Any,
"html": html,
"re": re,
}
exec(compile(ast.Module(body=[helper], type_ignores=[]), "app.py", "exec"), namespace)
title = namespace["_clean_presentation_title"](
"<b>E1001 팀 포트폴리오</b>"
)
self.assertEqual(title, "E1001 팀 포트폴리오")
self.assertIn('"title": _clean_presentation_title(title)', source)
self.assertIn(
'assistant_message["content"] = presentation_answer',
source,
)
self.assertIn(
"presentation_answer = _presentation_completion_answer(",
source,
)
self.assertIn(
"do not reproduce HTML tags, Markdown tables",
source,
)
def test_hmm_report_template_contains_only_dynamic_payload_slot(self) -> None:
template = (
Path(__file__).parents[1]