feat(regulatory): 支持按附件4章节核查
This commit is contained in:
@@ -163,6 +163,64 @@ def test_stream_message_starts_regulatory_workflow(monkeypatch, settings, django
|
||||
assert RegulatoryReviewBatch.objects.filter(conversation=conversation).exists()
|
||||
|
||||
|
||||
def test_stream_message_records_attachment4_chapter_scope(monkeypatch, settings, django_user_model):
|
||||
settings.REGULATORY_REVIEW_ASYNC = False
|
||||
user = django_user_model.objects.create_user(username="owner", password="pass")
|
||||
conversation = Conversation.objects.create(user=user, title="会话")
|
||||
FileSummaryBatch.objects.create(
|
||||
conversation=conversation,
|
||||
user=user,
|
||||
batch_no="FS-OK",
|
||||
status=FileSummaryBatch.Status.SUCCESS,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"review_agent.services.route_message_intent",
|
||||
lambda conversation, content: SkillRoute(
|
||||
action="regulatory_review",
|
||||
workflow_type="regulatory_review",
|
||||
confidence=0.9,
|
||||
),
|
||||
)
|
||||
|
||||
list(stream_message(conversation, "请做第一章 NMPA 法规核查"))
|
||||
|
||||
batch = RegulatoryReviewBatch.objects.get(conversation=conversation)
|
||||
assert batch.condition_json["rule_scope"]["attachment4_chapter"] == "1"
|
||||
assert batch.condition_json["rule_scope"]["label"] == "第1章 监管信息"
|
||||
|
||||
|
||||
def test_workflow_chapter_scope_only_checks_selected_attachment4_chapter(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,
|
||||
)
|
||||
batch = create_regulatory_review_batch(
|
||||
conversation=conversation,
|
||||
user=user,
|
||||
source_summary_batch=summary,
|
||||
)
|
||||
batch.condition_json = {
|
||||
"confirmed": True,
|
||||
"confirmed_conditions": {"product_category": "体外诊断试剂"},
|
||||
"rule_scope": {"attachment4_chapter": "1", "label": "第1章 监管信息"},
|
||||
}
|
||||
batch.save(update_fields=["condition_json"])
|
||||
|
||||
start_regulatory_review_workflow(batch, async_run=False)
|
||||
|
||||
issue_codes = list(RegulatoryIssue.objects.filter(batch=batch).values_list("rule_code", flat=True))
|
||||
assert issue_codes
|
||||
assert all(code.startswith("attachment4_1") for code in issue_codes)
|
||||
assert not any(code.startswith("attachment4_2") for code in issue_codes)
|
||||
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user