修复:CI 部署环境与 ref 错配、迁移碎片化、图片意图 source_span、章节物化脏版式、会话历史与本地语音不一致
新增:TTS 上传 COS 与分片、章节 reading_segments 物化与快照、markdown 清洗、会话消息 repository、语音 store 重构与相关测试
This commit is contained in:
@@ -8,10 +8,16 @@ from app.tasks.chapter_cover_enqueue import (
|
||||
)
|
||||
|
||||
|
||||
def _md_with_n_inline_images(n: int) -> str:
|
||||
lines = [f"" for i in range(n)]
|
||||
return "\n\n".join(lines) + "\n\n正文"
|
||||
|
||||
|
||||
def _eligible_pipeline_chapter():
|
||||
ch = MagicMock()
|
||||
ch.cover_asset_id = None
|
||||
ch.canonical_markdown = "some body"
|
||||
# 章节封面:正文内 asset 插图需 >3 才入队
|
||||
ch.canonical_markdown = _md_with_n_inline_images(4)
|
||||
ch.images = []
|
||||
return ch
|
||||
|
||||
@@ -69,6 +75,20 @@ def test_try_enqueue_true_when_eligible_and_nx_ok(mock_load, mock_redis, mock_ge
|
||||
r.set.assert_called_once()
|
||||
|
||||
|
||||
@patch("app.tasks.chapter_cover_tasks.generate_chapter_cover")
|
||||
@patch("app.tasks.chapter_cover_enqueue.redis.from_url")
|
||||
@patch("app.tasks.chapter_cover_enqueue._load_chapter_for_enqueue_sync")
|
||||
def test_try_enqueue_false_when_inline_images_not_enough(
|
||||
mock_load, mock_redis, mock_gen_task
|
||||
):
|
||||
ch = _eligible_pipeline_chapter()
|
||||
ch.canonical_markdown = _md_with_n_inline_images(3)
|
||||
mock_load.return_value = ch
|
||||
assert try_enqueue_generate_chapter_cover("ch-1", "pipeline") is False
|
||||
mock_gen_task.delay.assert_not_called()
|
||||
mock_redis.assert_not_called()
|
||||
|
||||
|
||||
@patch("app.tasks.chapter_cover_tasks.generate_chapter_cover")
|
||||
@patch("app.tasks.chapter_cover_enqueue.redis.from_url")
|
||||
@patch("app.tasks.chapter_cover_enqueue._load_chapter_for_enqueue_sync")
|
||||
|
||||
Reference in New Issue
Block a user