feat(regulatory): 输出法规核查过程日志

This commit is contained in:
2026-06-07 13:23:55 +08:00
parent 0f9fb980f2
commit 32d258bb75
8 changed files with 200 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
import logging
import pytest
from review_agent.models import (
@@ -147,6 +149,33 @@ def test_workflow_continues_when_llm_review_times_out(monkeypatch, settings, dja
assert batch.error_message == ""
def test_regulatory_workflow_logs_node_and_method_details(caplog, django_user_model):
user = django_user_model.objects.create_user(username="owner", password="pass")
conversation = Conversation.objects.create(user=user, title="会话")
summary = FileSummaryBatch.objects.create(
conversation=conversation,
user=user,
batch_no="FS-OK",
status=FileSummaryBatch.Status.SUCCESS,
)
batch = create_regulatory_review_batch(
conversation=conversation,
user=user,
source_summary_batch=summary,
)
batch.condition_json = {"confirmed": True, "confirmed_conditions": {"product_category": "体外诊断试剂"}}
batch.save(update_fields=["condition_json"])
with caplog.at_level(logging.INFO, logger="review_agent.regulatory_review.workflow"):
start_regulatory_review_workflow(batch, async_run=False)
messages = [record.getMessage() for record in caplog.records]
assert any("法规核查工作流开始" in message and batch.batch_no in message for message in messages)
assert any("节点开始" in message and "完整性核查" in message for message in messages)
assert any("方法执行" in message and "run_completeness_check" in message for message in messages)
assert any("节点完成" in message and "完整性核查" in message for message in messages)
def test_stream_message_prompts_for_summary_when_missing(monkeypatch, django_user_model):
user = django_user_model.objects.create_user(username="owner", password="pass")
conversation = Conversation.objects.create(user=user, title="会话")