test(regulatory-info-package): 覆盖材料包主链路
This commit is contained in:
36
tests/test_regulatory_info_package_field_extract.py
Normal file
36
tests/test_regulatory_info_package_field_extract.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from review_agent.regulatory_info_package.schemas import InstructionExtractResult
|
||||
from review_agent.regulatory_info_package.services.field_extract import extract_fields_by_rules, run_parallel_extract
|
||||
|
||||
|
||||
def test_extract_fields_by_rules_finds_product_name_and_storage():
|
||||
instruction = InstructionExtractResult(
|
||||
source_file_name="目标产品说明书.docx",
|
||||
paragraphs=["产品名称:新型冠状病毒检测试剂盒", "储存条件:2-8℃保存"],
|
||||
sections={},
|
||||
tables=[],
|
||||
component_tables=[],
|
||||
front_text="产品名称:新型冠状病毒检测试剂盒\n储存条件:2-8℃保存",
|
||||
)
|
||||
|
||||
result = extract_fields_by_rules(instruction)
|
||||
|
||||
assert result["product_name"]["value"] == "新型冠状病毒检测试剂盒"
|
||||
assert result["storage_condition"]["value"] == "2-8℃保存"
|
||||
|
||||
|
||||
def test_run_parallel_extract_keeps_rule_result_when_llm_fails():
|
||||
instruction = InstructionExtractResult(
|
||||
source_file_name="目标产品说明书.docx",
|
||||
paragraphs=["产品名称:测试产品"],
|
||||
sections={},
|
||||
tables=[],
|
||||
component_tables=[],
|
||||
front_text="产品名称:测试产品",
|
||||
)
|
||||
|
||||
result = run_parallel_extract(instruction, llm_extract_func=lambda _instruction: (_ for _ in ()).throw(ValueError("bad llm")))
|
||||
|
||||
assert result["regex_results"]["product_name"]["value"] == "测试产品"
|
||||
assert result["llm_results"] == {}
|
||||
assert result["llm_error"]
|
||||
|
||||
Reference in New Issue
Block a user