feat(regulatory): 增加风险归并与核查报告导出
This commit is contained in:
35
tests/test_regulatory_risk_assess.py
Normal file
35
tests/test_regulatory_risk_assess.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import pytest
|
||||
|
||||
from review_agent.models import Conversation, FileSummaryBatch, RegulatoryIssue, RegulatoryReviewBatch
|
||||
from review_agent.regulatory_review.schemas import Finding
|
||||
from review_agent.regulatory_review.services.risk_assess import persist_findings
|
||||
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
||||
def test_persist_findings_deduplicates_and_updates_risk_summary(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")
|
||||
batch = RegulatoryReviewBatch.objects.create(
|
||||
conversation=conversation,
|
||||
user=user,
|
||||
source_summary_batch=summary,
|
||||
batch_no="RR-RISK",
|
||||
)
|
||||
finding = Finding(
|
||||
rule_code="registration_test_report",
|
||||
category="completeness",
|
||||
severity="blocking",
|
||||
title="缺少注册检验报告",
|
||||
suggestion="请补充注册检验报告并复核。",
|
||||
citations=[{"source": "法规.doc", "text": "注册检验报告"}],
|
||||
)
|
||||
|
||||
issues = persist_findings(batch, [finding, finding])
|
||||
|
||||
batch.refresh_from_db()
|
||||
assert len(issues) == 1
|
||||
assert RegulatoryIssue.objects.count() == 1
|
||||
assert batch.risk_summary["blocking"] == 1
|
||||
Reference in New Issue
Block a user