fix(file-summary): 修复删除对话时受保护批次阻塞
This commit is contained in:
@@ -10,6 +10,7 @@ from review_agent.models import (
|
||||
FileAttachment,
|
||||
FileSummaryBatch,
|
||||
Message,
|
||||
RegulatoryReviewBatch,
|
||||
WorkflowNodeRun,
|
||||
)
|
||||
|
||||
@@ -269,6 +270,39 @@ def test_conversation_delete_api_removes_owned_conversation(client, django_user_
|
||||
assert Conversation.objects.filter(pk=other_conversation.pk).exists()
|
||||
|
||||
|
||||
def test_conversation_delete_api_removes_protected_workflow_dependents(client, django_user_model):
|
||||
user = django_user_model.objects.create_user(username="owner", password="pass")
|
||||
conversation = Conversation.objects.create(user=user, title="待删除")
|
||||
summary_batch = FileSummaryBatch.objects.create(
|
||||
conversation=conversation,
|
||||
user=user,
|
||||
batch_no="FS-DELETE-PROTECTED",
|
||||
)
|
||||
regulatory_batch = RegulatoryReviewBatch.objects.create(
|
||||
conversation=conversation,
|
||||
user=user,
|
||||
source_summary_batch=summary_batch,
|
||||
batch_no="RR-DELETE-PROTECTED",
|
||||
)
|
||||
form_batch = ApplicationFormFillBatch.objects.create(
|
||||
conversation=conversation,
|
||||
user=user,
|
||||
source_summary_batch=summary_batch,
|
||||
source_regulatory_batch=regulatory_batch,
|
||||
batch_no="AFF-DELETE-PROTECTED",
|
||||
)
|
||||
client.force_login(user)
|
||||
|
||||
response = client.delete(reverse("review_agent_conversation_detail", args=[conversation.pk]))
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json()["ok"] is True
|
||||
assert not Conversation.objects.filter(pk=conversation.pk).exists()
|
||||
assert not FileSummaryBatch.objects.filter(pk=summary_batch.pk).exists()
|
||||
assert not RegulatoryReviewBatch.objects.filter(pk=regulatory_batch.pk).exists()
|
||||
assert not ApplicationFormFillBatch.objects.filter(pk=form_batch.pk).exists()
|
||||
|
||||
|
||||
def test_conversation_delete_api_rejects_unowned_conversation(client, django_user_model):
|
||||
user = django_user_model.objects.create_user(username="owner", password="pass")
|
||||
other = django_user_model.objects.create_user(username="other", password="pass")
|
||||
|
||||
Reference in New Issue
Block a user