feat: 消费停录汇总与查结果同口径,并更新分类与 TSV
- 停录时由 details 经 build_consumption_summary 写 TSV/终端汇总,移除 consumption_log_totals 与时间窗累加 - 更新 consumable_classifier 权重、YAML 标签与 consumable_vision_algorithm - 扩展 consumption TSV 相关测试与配置注释 Made-with: Cursor
This commit is contained in:
@@ -13,6 +13,7 @@ from app.services.consumption_tsv_log import (
|
||||
build_consumption_markdown,
|
||||
build_tsv_line,
|
||||
init_consumption_log_file,
|
||||
replace_pending_line_with_voice_resolution,
|
||||
resolve_consumption_item_id,
|
||||
short_camera_label,
|
||||
)
|
||||
@@ -84,6 +85,43 @@ def test_header_columns() -> None:
|
||||
]
|
||||
|
||||
|
||||
def test_replace_pending_line_with_voice_resolution_rewrites_one_row(
|
||||
tmp_path: object,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""语音确认后应替换 pending 行,而不是再多一行。"""
|
||||
monkeypatch.setattr(settings, "consumption_tsv_log_enabled", True)
|
||||
monkeypatch.setattr(settings, "consumption_log_timezone", "UTC")
|
||||
monkeypatch.setattr(
|
||||
settings,
|
||||
"consumption_tsv_log_path",
|
||||
str(tmp_path / "{surgery_id}.txt"),
|
||||
)
|
||||
init_consumption_log_file("SURG01")
|
||||
pending = (
|
||||
"pending:abc-123\t待确认\t1\tvision\t"
|
||||
"cam01@2024-01-01T00:00:00.000+00:00"
|
||||
f"{_RANGE_SEP}2024-01-01T00:00:45.000+00:00\tx\t0.1\ty\t0.2\n"
|
||||
)
|
||||
append_consumption_tsv_line("SURG01", pending)
|
||||
replace_pending_line_with_voice_resolution(
|
||||
surgery_id="SURG01",
|
||||
confirmation_id="abc-123",
|
||||
name_to_code={"纱布": "G1"},
|
||||
chosen_label="纱布",
|
||||
doctor_id="voice",
|
||||
wall_epoch=1704067200.0,
|
||||
)
|
||||
text = (tmp_path / "SURG01.txt").read_text(encoding="utf-8")
|
||||
assert "待确认" not in text
|
||||
assert "pending:abc-123" not in text
|
||||
assert "纱布" in text
|
||||
assert "G1" in text
|
||||
# HEADER + 恰好一行数据
|
||||
data_lines = [ln for ln in text.splitlines() if ln and not ln.startswith("item_id\t")]
|
||||
assert len(data_lines) == 1
|
||||
|
||||
|
||||
def test_per_surgery_file_init_and_append(
|
||||
tmp_path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
|
||||
Reference in New Issue
Block a user