fix: 图片生成失败后重试 前端一直显示生成中

This commit is contained in:
yangshilin
2026-03-13 16:23:51 +08:00
parent e751114354
commit 672abf5ec7
7 changed files with 105 additions and 43 deletions

View File

@@ -307,13 +307,13 @@ class GenerateChapterImagesTaskTest(unittest.TestCase):
"AccessDenied", retryable=False, request_id="req-403"
)
task_self = SimpleNamespace(request=SimpleNamespace(id="task-1"), retry=Mock())
img_rec = chapter.sections[0].image_record
with self.assertRaises(memoir_tasks.PermanentImageGenerationError) as ctx:
generate_chapter_images.run.__func__(task_self, "chapter-1")
result = generate_chapter_images.run.__func__(task_self, "chapter-1")
self.assertIn("AccessDenied", str(ctx.exception))
self.assertEqual(chapter.sections[0].image_record.status, "failed")
self.assertIn("AccessDenied", chapter.sections[0].image_record.error)
self.assertEqual(result, {"status": "success"})
self.assertIsNone(chapter.sections[0].image_id)
db.delete.assert_called_with(img_rec)
task_self.retry.assert_not_called()
@patch("api.tasks.memoir_tasks.SessionLocal")