49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
from pathlib import Path
|
|||
|
|
|
||
|
|
from gfa_core.mas.agents.deepseek_summary import (
|
||
|
|
_validate_report,
|
||
|
|
collect_figure_inventory,
|
||
|
|
select_primary_scope,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def test_select_primary_scope_prefers_target_plus_reference() -> None:
|
||
|
|
summaries = [
|
||
|
|
{"stage": "identify", "scope_id": "YABBY.target-BNA.target_only"},
|
||
|
|
{"stage": "phylogeny", "scope_id": "YABBY.target-BNA.ref-At.target_plus_reference"},
|
||
|
|
{"stage": "motif", "scope_id": "YABBY.target-BNA.ref-At.target_plus_reference"},
|
||
|
|
]
|
||
|
|
|
||
|
|
assert select_primary_scope(summaries) == "YABBY.target-BNA.ref-At.target_plus_reference"
|
||
|
|
|
||
|
|
|
||
|
|
def test_collect_figure_inventory_deduplicates_identical_aliases(tmp_path: Path) -> None:
|
||
|
|
final_dir = tmp_path / "final"
|
||
|
|
final_dir.mkdir()
|
||
|
|
(final_dir / "A.tfbs_motif_source_summary.png").write_bytes(b"same-image")
|
||
|
|
(final_dir / "A.tfbs.motif_source_summary.png").write_bytes(b"same-image")
|
||
|
|
(final_dir / "A.pep_properties.png").write_bytes(b"different-image")
|
||
|
|
|
||
|
|
figures = collect_figure_inventory(final_dir, [], scope_id="scope")
|
||
|
|
|
||
|
|
assert len(figures) == 2
|
||
|
|
assert {item["stage"] for item in figures} == {"tfbs", "pep"}
|
||
|
|
|
||
|
|
|
||
|
|
def test_report_validation_requires_every_figure_marker() -> None:
|
||
|
|
figures = [
|
||
|
|
{"marker": "[[FIG:a.png]]"},
|
||
|
|
{"marker": "[[FIG:b.png]]"},
|
||
|
|
]
|
||
|
|
report = (
|
||
|
|
"# 报告\n\n任务 job_1\n\n"
|
||
|
|
+ "\n\n".join(f"## 章节{i}\n内容" for i in range(1, 10))
|
||
|
|
+ "\n\n[[FIG:a.png]]\n"
|
||
|
|
+ ("通俗解读。" * 800)
|
||
|
|
)
|
||
|
|
|
||
|
|
validation = _validate_report(report, job_id="job_1", figures=figures)
|
||
|
|
|
||
|
|
assert validation["passed"] is False
|
||
|
|
assert validation["missing_figure_markers"] == ["[[FIG:b.png]]"]
|