填写弹窗未落结论时默认任务状态已完成、结论通过(实验室与第三方); 每次保存追加操作留痕,卡片可查看修改时间线。关联 #148 #149。 Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
"""质检检测结果留痕:字段差异与空保存。"""
|
|
from app.crud.qc_task_result_change_log import build_result_changes
|
|
|
|
|
|
def test_build_changes_for_status_and_param():
|
|
before = {
|
|
"taskStatus": "dzx",
|
|
"conclusion": "",
|
|
"remark": "",
|
|
"attachments": "",
|
|
"params": {"paramCode:HBsAg": {"label": "HBsAg", "value": "阴性"}},
|
|
}
|
|
after = {
|
|
"taskStatus": "ywc",
|
|
"conclusion": "tg",
|
|
"remark": "",
|
|
"attachments": "",
|
|
"params": {"paramCode:HBsAg": {"label": "HBsAg", "value": "阳性"}},
|
|
}
|
|
changes = build_result_changes(before, after)
|
|
keys = {c["fieldKey"] for c in changes}
|
|
assert "taskStatus" in keys
|
|
assert "conclusion" in keys
|
|
assert "paramCode:HBsAg" in keys
|
|
hbs = next(c for c in changes if c["fieldKey"] == "paramCode:HBsAg")
|
|
assert hbs["oldValue"] == "阴性"
|
|
assert hbs["newValue"] == "阳性"
|
|
|
|
|
|
def test_build_changes_empty_when_identical():
|
|
state = {
|
|
"taskStatus": "ywc",
|
|
"conclusion": "tg",
|
|
"remark": "ok",
|
|
"attachments": "a.png",
|
|
"params": {"paramCode:X": {"label": "X", "value": "1"}},
|
|
}
|
|
assert build_result_changes(state, state) == []
|