feat(api): initialize memoir chapter image assets on creation
Made-with: Cursor
This commit is contained in:
26
api/tests/test_memoir_image_bootstrap.py
Normal file
26
api/tests/test_memoir_image_bootstrap.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from api.tasks.memoir_tasks import initialize_chapter_images
|
||||
|
||||
|
||||
class MemoirImageBootstrapTest(unittest.TestCase):
|
||||
@patch("api.tasks.memoir_tasks.generate_chapter_images.delay")
|
||||
def test_initialize_chapter_images_sets_pending_assets_and_enqueues_task(self, delay_mock):
|
||||
chapter = type(
|
||||
"ChapterStub",
|
||||
(),
|
||||
{
|
||||
"id": "chapter-1",
|
||||
"title": "童年的夏天",
|
||||
"category": "childhood",
|
||||
"content": "那条路我一直记得。\n\n{{{{IMAGE:南方小镇的青石板路}}}}",
|
||||
"images": [],
|
||||
},
|
||||
)()
|
||||
|
||||
assets = initialize_chapter_images(chapter)
|
||||
|
||||
self.assertEqual(len(assets), 1)
|
||||
self.assertEqual(assets[0]["status"], "pending")
|
||||
delay_mock.assert_called_once_with("chapter-1")
|
||||
Reference in New Issue
Block a user