-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_preview_ui.py
More file actions
59 lines (51 loc) · 1.86 KB
/
Copy pathtest_preview_ui.py
File metadata and controls
59 lines (51 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""UI preview regression checks for Chinese-facing display text."""
import converter
def check(cond, msg):
if cond:
print(f"ok : {msg}")
else:
raise AssertionError(msg)
sample = {
"schema_version": "1.0",
"metadata": {
"title": "归来",
"language": "zh-CN",
"logline": "陈志远回到家乡。",
"source_chapters": [1],
},
"characters": [
{"id": "char_chen", "name": "陈志远", "role": "protagonist"},
],
"scenes": [
{
"id": "scene_001",
"number": 1,
"slugline": {
"int_ext": "EXT",
"location": "村口石桥",
"time_of_day": "MORNING",
},
"summary": "陈志远回到村口。",
"elements": [
{"type": "action", "text": "雨停了。"},
{
"type": "dialogue",
"character_id": "char_chen",
"character_cue": "陈志远",
"delivery": "V.O.",
"parenthetical": "低声",
"text": "我回来了。",
},
],
}
],
}
preview = converter.render_preview(sample)
check("外景" in preview, "#1 EXT 应显示为中文外景")
check("清晨" in preview, "#2 MORNING 应显示为中文清晨")
check("EXT" not in preview and "MORNING" not in preview, "#3 预览不应露出英文场景码")
check("画外音" in preview and "V.O." not in preview, "#4 delivery 应显示为中文")
check("(低声)" in preview, "#5 parenthetical 应使用中文括号")
check("陈志远" in preview and ":</span><span" in preview, "#6 对白应使用紧凑中文冒号格式")
check("陈志远 :" not in preview, "#7 对白人物名与冒号之间不应有空格")
print("\n✅ test_preview_ui: 全部断言通过")