|
@@ -9,6 +9,23 @@ GENERATOR = ROOT / "scripts" / "generate_cpld_teaching_html.py"
|
|
|
VALIDATOR = ROOT / "scripts" / "validate_cpld_teaching_html.py"
|
|
VALIDATOR = ROOT / "scripts" / "validate_cpld_teaching_html.py"
|
|
|
CONTENT = ROOT / "workspace" / "teaching_content" / "chapters" / "cpld_teaching_content.json"
|
|
CONTENT = ROOT / "workspace" / "teaching_content" / "chapters" / "cpld_teaching_content.json"
|
|
|
|
|
|
|
|
|
|
+GENERIC_NARRATION_MARKERS = [
|
|
|
|
|
+ "讨论「",
|
|
|
|
|
+ "读者真正会遇到的不是抽象名词",
|
|
|
|
|
+ "这个现象要落到证据上看",
|
|
|
|
|
+ "顺着这个点往下学",
|
|
|
|
|
+ "放进系统里看",
|
|
|
|
|
+ "扩展学习时不要把",
|
|
|
|
|
+ "讲解时可以采用一个很小的实验",
|
|
|
|
|
+ "不要从术语背诵开始",
|
|
|
|
|
+ "自然串讲:从现象走到验证",
|
|
|
|
|
+ "工程化深挖",
|
|
|
|
|
+ "常见误判要单独拎出来",
|
|
|
|
|
+ "本节的交付标准是",
|
|
|
|
|
+ "问题链自问",
|
|
|
|
|
+ "最小复述标准",
|
|
|
|
|
+]
|
|
|
|
|
+
|
|
|
|
|
|
|
|
def run_cmd(*args: str) -> subprocess.CompletedProcess[str]:
|
|
def run_cmd(*args: str) -> subprocess.CompletedProcess[str]:
|
|
|
return subprocess.run(
|
|
return subprocess.run(
|
|
@@ -54,12 +71,16 @@ def test_generator_creates_all_thirteen_single_file_reports(tmp_path: Path) -> N
|
|
|
assert "class=\"evidence-panel\"" in ch5
|
|
assert "class=\"evidence-panel\"" in ch5
|
|
|
assert "class=\"section learning-ladder\"" in ch5
|
|
assert "class=\"section learning-ladder\"" in ch5
|
|
|
assert "class=\"section knowledge-system\"" in ch5
|
|
assert "class=\"section knowledge-system\"" in ch5
|
|
|
- assert "class=\"section-thread\"" in ch5
|
|
|
|
|
|
|
+ assert "class=\"section-story\"" in ch5
|
|
|
|
|
+ assert "class=\"progressive-note\"" in ch5
|
|
|
|
|
+ assert "class=\"section-thread\"" not in ch5
|
|
|
assert "从浅到深的学习阶梯" in ch5
|
|
assert "从浅到深的学习阶梯" in ch5
|
|
|
assert "本章知识系统" in ch5
|
|
assert "本章知识系统" in ch5
|
|
|
assert "本节的交付标准是读者能把" not in ch5
|
|
assert "本节的交付标准是读者能把" not in ch5
|
|
|
assert "常见误判要单独拎出来" not in ch5
|
|
assert "常见误判要单独拎出来" not in ch5
|
|
|
assert "复盘本章时建议按下面的问题链自问" not in ch5
|
|
assert "复盘本章时建议按下面的问题链自问" not in ch5
|
|
|
|
|
+ for marker in GENERIC_NARRATION_MARKERS:
|
|
|
|
|
+ assert marker not in ch5
|
|
|
|
|
|
|
|
ch13 = (tmp_path / "cpld_ch13_program_debug_runbook_learning_report_v1.html").read_text(encoding="utf-8")
|
|
ch13 = (tmp_path / "cpld_ch13_program_debug_runbook_learning_report_v1.html").read_text(encoding="utf-8")
|
|
|
assert "No hardware" in ch13
|
|
assert "No hardware" in ch13
|
|
@@ -67,6 +88,18 @@ def test_generator_creates_all_thirteen_single_file_reports(tmp_path: Path) -> N
|
|
|
assert "id=\"debugTree\"" in ch13
|
|
assert "id=\"debugTree\"" in ch13
|
|
|
assert "VREF 不供电" in ch13
|
|
assert "VREF 不供电" in ch13
|
|
|
assert "class=\"causal-grid\"" not in ch13
|
|
assert "class=\"causal-grid\"" not in ch13
|
|
|
|
|
+ for marker in GENERIC_NARRATION_MARKERS:
|
|
|
|
|
+ assert marker not in ch13
|
|
|
|
|
+
|
|
|
|
|
+ for file_name in [
|
|
|
|
|
+ "cpld_ch6_i2c_control_learning_report_v1.html",
|
|
|
|
|
+ "cpld_ch11_pid_24ch_learning_report_v1.html",
|
|
|
|
|
+ ]:
|
|
|
|
|
+ text = (tmp_path / file_name).read_text(encoding="utf-8")
|
|
|
|
|
+ assert "class=\"section-story\"" in text
|
|
|
|
|
+ assert "class=\"progressive-note\"" in text
|
|
|
|
|
+ for marker in GENERIC_NARRATION_MARKERS:
|
|
|
|
|
+ assert marker not in text
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_validator_accepts_generated_reports_and_writes_json_receipt(tmp_path: Path) -> None:
|
|
def test_validator_accepts_generated_reports_and_writes_json_receipt(tmp_path: Path) -> None:
|
|
@@ -88,9 +121,10 @@ def test_validator_accepts_generated_reports_and_writes_json_receipt(tmp_path: P
|
|
|
assert payload["checks"]["mechanical_join"]["passed"] is True
|
|
assert payload["checks"]["mechanical_join"]["passed"] is True
|
|
|
assert payload["checks"]["learning_progression"]["passed"] is True
|
|
assert payload["checks"]["learning_progression"]["passed"] is True
|
|
|
assert payload["checks"]["knowledge_system"]["passed"] is True
|
|
assert payload["checks"]["knowledge_system"]["passed"] is True
|
|
|
|
|
+ assert payload["checks"]["natural_section_story"]["passed"] is True
|
|
|
|
|
|
|
|
|
|
|
|
|
-def test_content_source_models_progressive_learning_and_system_context() -> None:
|
|
|
|
|
|
|
+def test_content_source_models_section_specific_progressive_learning_and_system_context() -> None:
|
|
|
data = json.loads(CONTENT.read_text(encoding="utf-8-sig"))
|
|
data = json.loads(CONTENT.read_text(encoding="utf-8-sig"))
|
|
|
|
|
|
|
|
for chapter in data["chapters"]:
|
|
for chapter in data["chapters"]:
|
|
@@ -101,10 +135,24 @@ def test_content_source_models_progressive_learning_and_system_context() -> None
|
|
|
assert any(word in ladder_text for word in ["扩展", "系统", "集成", "排障"]), chapter["short"]
|
|
assert any(word in ladder_text for word in ["扩展", "系统", "集成", "排障"]), chapter["short"]
|
|
|
|
|
|
|
|
for section in chapter["sections"]:
|
|
for section in chapter["sections"]:
|
|
|
- path = section.get("learning_path", [])
|
|
|
|
|
- assert len(path) >= 3, section["title"]
|
|
|
|
|
- assert section.get("system_hint"), section["title"]
|
|
|
|
|
- assert section.get("mentor_note"), section["title"]
|
|
|
|
|
|
|
+ assert "mentor_note" not in section, section["title"]
|
|
|
|
|
+ assert "learning_path" not in section, section["title"]
|
|
|
|
|
+ assert "system_hint" not in section, section["title"]
|
|
|
|
|
+ for field in [
|
|
|
|
|
+ "beginner_entry",
|
|
|
|
|
+ "engineering_story",
|
|
|
|
|
+ "mechanism_walkthrough",
|
|
|
|
|
+ "verification_story",
|
|
|
|
|
+ "system_extension",
|
|
|
|
|
+ ]:
|
|
|
|
|
+ value = section.get(field, "")
|
|
|
|
|
+ assert len(value) >= 80, f"{section['title']} missing {field}"
|
|
|
|
|
+ assert section["title"][:4] in value or any(anchor in value for anchor in section["anchors"]), (
|
|
|
|
|
+ section["title"],
|
|
|
|
|
+ field,
|
|
|
|
|
+ )
|
|
|
|
|
+ for marker in GENERIC_NARRATION_MARKERS:
|
|
|
|
|
+ assert marker not in value
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_validator_rejects_old_template_repetition(tmp_path: Path) -> None:
|
|
def test_validator_rejects_old_template_repetition(tmp_path: Path) -> None:
|