init: 项目初始提交 - NeoZQYY Monorepo 完整代码
This commit is contained in:
69
tests/test_property_readme_structure.py
Normal file
69
tests/test_property_readme_structure.py
Normal file
@@ -0,0 +1,69 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
README.md 结构完整性属性测试
|
||||
|
||||
**Validates: Requirements 1.5**
|
||||
|
||||
Property 1: 对于任意 Monorepo 一级目录,其 README.md 文件应存在
|
||||
且包含"作用说明"、"结构描述"和"Roadmap"三个段落。
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
|
||||
from hypothesis import given, settings
|
||||
from hypothesis.strategies import sampled_from
|
||||
|
||||
# Monorepo 根目录
|
||||
MONOREPO_ROOT = r"C:\NeoZQYY"
|
||||
|
||||
# 一级目录列表(需求 1.5 定义)
|
||||
TOP_LEVEL_DIRS = [
|
||||
"apps",
|
||||
"gui",
|
||||
"packages",
|
||||
"db",
|
||||
"docs",
|
||||
"infra",
|
||||
"scripts",
|
||||
"samples",
|
||||
"tests",
|
||||
]
|
||||
|
||||
|
||||
@settings(max_examples=100)
|
||||
@given(dir_name=sampled_from(TOP_LEVEL_DIRS))
|
||||
def test_readme_structure_completeness(dir_name: str) -> None:
|
||||
"""
|
||||
Property 1: README.md 结构完整性
|
||||
|
||||
**Validates: Requirements 1.5**
|
||||
|
||||
对于任意一级目录,验证:
|
||||
1. README.md 文件存在
|
||||
2. 包含"作用说明"段落标题
|
||||
3. 包含"内部结构"或"结构"段落标题
|
||||
4. 包含"Roadmap"段落标题
|
||||
"""
|
||||
readme_path = os.path.join(MONOREPO_ROOT, dir_name, "README.md")
|
||||
|
||||
# README.md 必须存在
|
||||
assert os.path.isfile(readme_path), (
|
||||
f"{dir_name}/README.md 不存在: {readme_path}"
|
||||
)
|
||||
|
||||
content = open(readme_path, encoding="utf-8").read()
|
||||
|
||||
# 包含"作用说明"段落标题
|
||||
assert re.search(r"^#{1,3}\s*作用说明", content, re.MULTILINE), (
|
||||
f"{dir_name}/README.md 缺少'作用说明'段落"
|
||||
)
|
||||
|
||||
# 包含"结构"相关段落标题(内部结构 或 结构)
|
||||
assert re.search(r"^#{1,3}\s*(内部)?结构", content, re.MULTILINE), (
|
||||
f"{dir_name}/README.md 缺少'结构'段落"
|
||||
)
|
||||
|
||||
# 包含"Roadmap"段落标题
|
||||
assert re.search(r"^#{1,3}\s*Roadmap", content, re.MULTILINE | re.IGNORECASE), (
|
||||
f"{dir_name}/README.md 缺少'Roadmap'段落"
|
||||
)
|
||||
Reference in New Issue
Block a user