feat(regulatory): 增加风险归并与核查报告导出
This commit is contained in:
49
tests/test_regulatory_export.py
Normal file
49
tests/test_regulatory_export.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from review_agent.models import (
|
||||
Conversation,
|
||||
ExportedSummaryFile,
|
||||
FileSummaryBatch,
|
||||
RegulatoryIssue,
|
||||
RegulatoryReviewBatch,
|
||||
)
|
||||
from review_agent.regulatory_review.services.export import export_review_results
|
||||
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
||||
def test_export_review_results_creates_markdown_excel_and_json(settings, tmp_path, django_user_model):
|
||||
settings.MEDIA_ROOT = tmp_path
|
||||
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-EXPORT",
|
||||
risk_summary={"blocking": 1},
|
||||
)
|
||||
RegulatoryIssue.objects.create(
|
||||
batch=batch,
|
||||
rule_code="registration_test_report",
|
||||
category=RegulatoryIssue.Category.COMPLETENESS,
|
||||
severity=RegulatoryIssue.Severity.BLOCKING,
|
||||
title="缺少注册检验报告",
|
||||
suggestion="请补充注册检验报告并复核。",
|
||||
)
|
||||
|
||||
exports = export_review_results(batch)
|
||||
|
||||
assert {export.export_type for export in exports} == {
|
||||
ExportedSummaryFile.ExportType.MARKDOWN,
|
||||
ExportedSummaryFile.ExportType.EXCEL,
|
||||
ExportedSummaryFile.ExportType.JSON,
|
||||
}
|
||||
json_export = next(export for export in exports if export.export_type == ExportedSummaryFile.ExportType.JSON)
|
||||
payload = json.loads(open(json_export.storage_path, encoding="utf-8").read())
|
||||
assert payload["batch_no"] == "RR-EXPORT"
|
||||
assert payload["issues"][0]["title"] == "缺少注册检验报告"
|
||||
Reference in New Issue
Block a user