修复:CI 部署环境与 ref 错配、迁移碎片化、图片意图 source_span、章节物化脏版式、会话历史与本地语音不一致
新增:TTS 上传 COS 与分片、章节 reading_segments 物化与快照、markdown 清洗、会话消息 repository、语音 store 重构与相关测试
This commit is contained in:
27
api/tests/test_markdown_sanitize.py
Normal file
27
api/tests/test_markdown_sanitize.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import unittest
|
||||
|
||||
from app.features.memoir.markdown_sanitize import (
|
||||
sanitize_story_for_chapter_compose,
|
||||
strip_leading_heading_if_matches_title,
|
||||
strip_markdown_tables,
|
||||
)
|
||||
|
||||
|
||||
class MarkdownSanitizeTest(unittest.TestCase):
|
||||
def test_strip_table_block(self):
|
||||
md = "第一段\n\n| a | b |\n| - | - |\n| 1 | 2 |\n\n第二段"
|
||||
out = strip_markdown_tables(md)
|
||||
self.assertNotIn("| a |", out)
|
||||
self.assertIn("第一段", out)
|
||||
self.assertIn("第二段", out)
|
||||
|
||||
def test_strip_heading_when_matches_title(self):
|
||||
body = "## 童年\n\n正文"
|
||||
out = strip_leading_heading_if_matches_title(body, "童年")
|
||||
self.assertEqual(out, "正文")
|
||||
|
||||
def test_sanitize_compose(self):
|
||||
raw = "| x | y |\n|---|---|\n|1|2|\n\n你好"
|
||||
out = sanitize_story_for_chapter_compose(raw, "T")
|
||||
self.assertIn("你好", out)
|
||||
self.assertNotIn("| x |", out)
|
||||
Reference in New Issue
Block a user