fix(regulatory-info-package): 完成后追加下载摘要
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from review_agent.models import Conversation, RegulatoryInfoPackageBatch, WorkflowNodeRun
|
||||
from review_agent.models import Conversation, FileAttachment, Message, RegulatoryInfoPackageBatch, WorkflowNodeRun
|
||||
from review_agent.regulatory_info_package.constants import (
|
||||
REGULATORY_INFO_PACKAGE_NODE_DEFINITIONS,
|
||||
WORKFLOW_TYPE,
|
||||
@@ -60,3 +62,31 @@ def test_empty_workflow_skeleton_completes(django_user_model, settings):
|
||||
status=WorkflowNodeRun.Status.SUCCESS,
|
||||
).count() == len(REGULATORY_INFO_PACKAGE_NODE_DEFINITIONS)
|
||||
|
||||
|
||||
def test_completed_workflow_appends_download_summary_message(django_user_model, settings):
|
||||
settings.REGULATORY_INFO_PACKAGE_ASYNC = False
|
||||
user = django_user_model.objects.create_user(username="owner", password="pass")
|
||||
conversation = Conversation.objects.create(user=user, title="会话")
|
||||
trigger = Message.objects.create(conversation=conversation, role=Message.Role.USER, content="根据说明书生成第1章监管信息")
|
||||
source = Path("docs/0.原始材料/目标产品说明书.docx").resolve()
|
||||
attachment = FileAttachment.objects.create(
|
||||
conversation=conversation,
|
||||
user=user,
|
||||
original_name="目标产品说明书.docx",
|
||||
storage_path=str(source),
|
||||
file_size=source.stat().st_size,
|
||||
)
|
||||
batch = create_regulatory_info_package_batch(
|
||||
conversation=conversation,
|
||||
user=user,
|
||||
trigger_message=trigger,
|
||||
source_attachment=attachment,
|
||||
source_file_name=attachment.original_name,
|
||||
source_storage_path=attachment.storage_path,
|
||||
)
|
||||
|
||||
start_regulatory_info_package_workflow(batch, async_run=False)
|
||||
|
||||
message = conversation.messages.filter(role=Message.Role.ASSISTANT, content__contains=batch.batch_no).latest("id")
|
||||
assert "第1章 监管信息(预生成版).zip" in message.content
|
||||
assert "/api/review-agent/file-summary/exports/" in message.content
|
||||
|
||||
Reference in New Issue
Block a user