feat(regulatory): 增加风险归并与核查报告导出
This commit is contained in:
@@ -2,8 +2,11 @@ import pytest
|
||||
|
||||
from review_agent.models import (
|
||||
Conversation,
|
||||
ExportedSummaryFile,
|
||||
FileSummaryBatch,
|
||||
FileSummaryItem,
|
||||
Message,
|
||||
RegulatoryIssue,
|
||||
RegulatoryReviewBatch,
|
||||
WorkflowEvent,
|
||||
WorkflowNodeRun,
|
||||
@@ -155,3 +158,43 @@ def test_stream_message_starts_regulatory_workflow(monkeypatch, settings, django
|
||||
assert "workflow_started" in joined
|
||||
assert "\"workflow_type\": \"regulatory_review\"" in joined
|
||||
assert RegulatoryReviewBatch.objects.filter(conversation=conversation).exists()
|
||||
|
||||
|
||||
def test_workflow_generates_issues_exports_and_assistant_summary(settings, tmp_path, django_user_model):
|
||||
settings.MEDIA_ROOT = tmp_path
|
||||
settings.REGULATORY_REVIEW_ASYNC = False
|
||||
settings.REGULATORY_RAG_CHROMA_PATH = tmp_path / "missing-rag"
|
||||
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,
|
||||
)
|
||||
ifu_path = tmp_path / "ifu.txt"
|
||||
ifu_path.write_text("产品名称:甲胎蛋白检测试剂盒\n样本要求:血清\n有效期:12个月", encoding="utf-8")
|
||||
FileSummaryItem.objects.create(
|
||||
batch=summary,
|
||||
file_index=1,
|
||||
file_name="说明书.txt",
|
||||
file_type="txt",
|
||||
relative_path="说明书.txt",
|
||||
storage_path=str(ifu_path),
|
||||
)
|
||||
batch = create_regulatory_review_batch(
|
||||
conversation=conversation,
|
||||
user=user,
|
||||
source_summary_batch=summary,
|
||||
)
|
||||
|
||||
start_regulatory_review_workflow(batch, async_run=False)
|
||||
|
||||
batch.refresh_from_db()
|
||||
assert batch.status == RegulatoryReviewBatch.Status.SUCCESS
|
||||
assert RegulatoryIssue.objects.filter(batch=batch, severity="blocking").exists()
|
||||
assert ExportedSummaryFile.objects.filter(
|
||||
workflow_type="regulatory_review",
|
||||
workflow_batch_id=batch.pk,
|
||||
).count() == 3
|
||||
assert conversation.messages.filter(role=Message.Role.ASSISTANT, content__contains="已完成 NMPA").exists()
|
||||
|
||||
Reference in New Issue
Block a user