fix(regulatory): 修复换行产品名称提取不全

This commit is contained in:
2026-06-07 11:30:48 +08:00
parent 72f18167c5
commit a34684e490
3 changed files with 79 additions and 4 deletions

View File

@@ -82,6 +82,41 @@ def test_detect_regulatory_condition_prefers_attachment_fields_over_chapter_titl
assert candidates["intended_use"]["suggested"] == "用于人血清中甲胎蛋白检测"
def test_detect_regulatory_condition_keeps_wrapped_product_name(settings, tmp_path, django_user_model):
settings.MEDIA_ROOT = tmp_path
user = django_user_model.objects.create_user(username="owner", password="pass")
conversation = Conversation.objects.create(user=user, title="会话")
summary = FileSummaryBatch.objects.create(
conversation=conversation,
user=user,
batch_no="FS-COND",
status=FileSummaryBatch.Status.SUCCESS,
product_name="第1章 监管信息",
)
application = tmp_path / "application.txt"
application.write_text(
"产品名称:呼吸道合胞病毒、肺炎支原体核酸检测试剂盒\n"
"荧光PCR法\n"
"型号规格24人份/盒\n"
"预期用途:用于呼吸道合胞病毒、肺炎支原体核酸检测\n",
encoding="utf-8",
)
FileSummaryItem.objects.create(
batch=summary,
file_index=1,
directory_level="1. 监管信息 / 1.2 申请表",
file_name="申请表.txt",
file_type="txt",
relative_path="1.监管信息/申请表.txt",
storage_path=str(application),
)
candidates = detect_regulatory_condition_candidates(summary)
assert candidates["product_name"]["suggested"] == "呼吸道合胞病毒、肺炎支原体核酸检测试剂盒 荧光PCR法"
assert candidates["model_spec"]["suggested"] == "24人份/盒"
def test_workflow_pauses_before_rule_scope_until_conditions_confirmed(settings, tmp_path, django_user_model):
settings.MEDIA_ROOT = tmp_path
user = django_user_model.objects.create_user(username="owner", password="pass")