27 lines
895 B
Python
27 lines
895 B
Python
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")
|