fix: share precise scoring failure labels across API chat and exports

This commit is contained in:
2026-10-18 12:16:04 +08:00
parent 000638718c
commit ba5a6952bb
3 changed files with 47 additions and 6 deletions
+24
View File
@@ -293,6 +293,30 @@ def test_pdf_html_preserves_zero_and_none():
assert "实验(0 / 10)" in html and "模型原始分:0" in html
@pytest.mark.parametrize("error, label", [
("模型证据未关联该片段的检索目标", "模型输出校验失败"),
("模型请求或JSON校验失败(ConnectError:无法连接模型端点),已重试2次", "模型连接失败"),
("模型请求或JSON校验失败(模型请求超时,请稍后重试),已重试2次", "模型连接失败"),
("模型请求或JSON校验失败(HTTP 429:请求限流),已重试2次", "模型请求失败"),
("模型请求或JSON校验失败(ValidationError:模型返回字段不符合格式),已重试2次", "模型输出校验失败"),
("后台数据处理异常", "评分失败"),
])
def test_score_api_and_export_share_precise_failure_labels(sqlite_db, error, label):
from wisegrade.exports import project_result
db = sqlite_db
item = project(db)
created = services.create_batch(SimpleNamespace(course_version_id=1, rubric_version_id=1), db)
batch = db.get(ScoringBatch, created["id"])
criterion = batch.rubric_snapshot["criteria"][0]
db.add(CriterionScore(batch_id=batch.id, project_id=item.id,
criterion_id=criterion["criterion_id"], status="failed", error=error))
db.commit()
result = project_result(db, batch, item)
assert result["rows"][0]["status_label"] == label
assert f"状态:{label}" in _html_report(result, batch)
assert result["rows"][0]["model_score"] is None
def test_public_reindex_uses_saved_pages(sqlite_db):
db = sqlite_db
doc = document(db, None, "课程资料")