init: 项目初始提交 - NeoZQYY Monorepo 完整代码
This commit is contained in:
64
tests/test_property_steering_paths.py
Normal file
64
tests/test_property_steering_paths.py
Normal file
@@ -0,0 +1,64 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Steering 文件路径更新属性测试
|
||||
|
||||
**Validates: Requirements 10.2**
|
||||
|
||||
Property 9: 对于任意 .kiro/steering/ 目录下的文件,
|
||||
文件内容中不应包含旧仓库路径引用(如 FQ-ETL、C:\\ZQYY\\FQ-ETL)。
|
||||
|
||||
测试逻辑:
|
||||
1. 列出 .kiro/steering/ 下所有 .md 文件
|
||||
2. 使用 hypothesis sampled_from 随机选取
|
||||
3. 读取文件内容,验证不包含旧路径引用
|
||||
"""
|
||||
import os
|
||||
import glob
|
||||
|
||||
from hypothesis import given, settings
|
||||
from hypothesis.strategies import sampled_from
|
||||
|
||||
# ── 路径常量 ──────────────────────────────────────────────
|
||||
MONOREPO_ROOT = r"C:\NeoZQYY"
|
||||
STEERING_DIR = os.path.join(MONOREPO_ROOT, ".kiro", "steering")
|
||||
|
||||
# 旧仓库路径模式(需要检测并确认已清除的字符串)
|
||||
OLD_PATH_PATTERNS = [
|
||||
"FQ-ETL",
|
||||
r"C:\ZQYY\FQ-ETL",
|
||||
r"C:\\ZQYY\\FQ-ETL",
|
||||
]
|
||||
|
||||
# ── 预加载 steering 文件列表(模块级,只扫描一次) ────────────
|
||||
STEERING_FILES: list[str] = sorted(
|
||||
glob.glob(os.path.join(STEERING_DIR, "*.md"))
|
||||
)
|
||||
|
||||
assert len(STEERING_FILES) > 0, (
|
||||
f"未在 {STEERING_DIR} 下找到任何 .md 文件,请检查目录是否存在"
|
||||
)
|
||||
|
||||
|
||||
# ── 属性测试 ──────────────────────────────────────────────
|
||||
|
||||
@given(filepath=sampled_from(STEERING_FILES))
|
||||
@settings(max_examples=100)
|
||||
def test_steering_files_no_old_repo_paths(filepath: str):
|
||||
"""
|
||||
Property 9: Steering 文件路径更新
|
||||
|
||||
对于任意 .kiro/steering/ 目录下的 .md 文件,
|
||||
文件内容中不应包含旧仓库路径引用。
|
||||
这确保迁移后所有 steering 文件已更新为 Monorepo 视角。
|
||||
|
||||
**Validates: Requirements 10.2**
|
||||
"""
|
||||
with open(filepath, encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
|
||||
filename = os.path.basename(filepath)
|
||||
for pattern in OLD_PATH_PATTERNS:
|
||||
assert pattern not in content, (
|
||||
f"[{filename}] 仍包含旧仓库路径引用: '{pattern}'\n"
|
||||
f"请更新该文件,移除所有旧路径(FQ-ETL / C:\\ZQYY\\FQ-ETL)"
|
||||
)
|
||||
Reference in New Issue
Block a user