Files
Jeffery (jiantw83)andClaude Sonnet 5.5 697ed6a0b9 feat: 亞絲娜與直葉的角色包 (#6, #7)
build_pack.py 產生對白索引(放在使用者資料目錄);render_skill.py 把人格卡渲染成
角色 skill 並檢查精選對白逐字來自索引;插件改成執行期從資料目錄讀索引。

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 20:52:40 +00:00

36 lines
1.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import unittest
import render_skill
CARD = """## 語氣與口癖
- 例 (v1c01-0001)
## 精選對白
- [v1c01-0001] greet/joy:「好久不見了,艾基爾」
- [v1c01-0002] tease/neutral:「你穿得一身黑有什麼理由嗎?」
"""
ROWS = [{"id": "v1c01-0001", "text": "好久不見了,艾基爾"}, {"id": "v1c01-0002", "text": "你穿得一身黑有什麼理由嗎?"}]
class Render(unittest.TestCase):
def test_selected_quotes(self):
self.assertEqual(render_skill.selected_quotes(CARD)[0], ("v1c01-0001", "好久不見了,艾基爾"))
self.assertEqual(len(render_skill.selected_quotes(CARD)), 2)
def test_check_quotes_accepts_verbatim_and_flags_changes(self):
self.assertEqual(render_skill.check_quotes(CARD, ROWS), [])
self.assertEqual(len(render_skill.check_quotes(CARD, [ROWS[0], {"id": "v1c01-0002", "text": "改過的句子"}])), 1)
self.assertEqual(len(render_skill.check_quotes(CARD, ROWS[:1])), 1)
def test_render_has_frontmatter_demotes_headings_and_keeps_rules(self):
out = render_skill.render(CARD, "sao-suguha")
self.assertTrue(out.startswith("---\nname: sao-suguha\n"))
self.assertIn("### 語氣與口癖", out)
self.assertNotIn("\n## 精選對白", out)
self.assertIn("哥哥", out)
self.assertIn("先用一句清楚的話說完", out)
if __name__ == "__main__":
unittest.main()