feat(regulatory): 对齐附件4目录核查规则
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
import pytest
|
||||
from django.core.management import call_command
|
||||
@@ -27,6 +28,30 @@ def test_load_rule_file_reads_demo_requirements():
|
||||
assert "essential_principles_checklist" in codes
|
||||
|
||||
|
||||
def test_load_rule_file_covers_attachment4_outline():
|
||||
rule_set = load_rule_file()
|
||||
requirements = rule_set["requirements"]
|
||||
outline = json.loads(Path("tests/fixtures/regulatory/attachment4_outline.json").read_text(encoding="utf-8"))
|
||||
|
||||
for chapter in outline:
|
||||
chapter_rule = next(
|
||||
item for item in requirements if item["title"] == chapter["title"] and item.get("attachment4_code") == chapter["code"]
|
||||
)
|
||||
assert chapter_rule["attachment4_code"] == chapter["code"]
|
||||
assert chapter_rule["severity"] == "high"
|
||||
assert chapter_rule["citation_query"]
|
||||
for child in chapter["children"]:
|
||||
child_rule = next(
|
||||
item
|
||||
for item in requirements
|
||||
if item["title"] == child and str(item.get("attachment4_code", "")).startswith(f"{chapter['code']}.")
|
||||
)
|
||||
assert child_rule["rule_id"]
|
||||
assert child_rule["file_keywords"]
|
||||
assert child_rule["severity"] in {"blocking", "high", "medium"}
|
||||
assert child_rule["citation_query"]
|
||||
|
||||
|
||||
def test_compute_file_sha256_changes_when_file_changes(tmp_path):
|
||||
path = tmp_path / "rule.yaml"
|
||||
path.write_text("code: demo\n", encoding="utf-8")
|
||||
|
||||
Reference in New Issue
Block a user