修复内容: - E2E测试命令执行方式:将 python -m uv run 改为 uv run - HTML渲染器:添加 & 字符的HTML转义 - Presentation尺寸验证:添加尺寸值类型验证 - PPTX验证器:修复文本框检测兼容性 - 验证结果格式化:修复提示信息显示 - Mock配置:修复表格渲染等测试的Mock配置 测试结果: - 修复前: 264 通过, 42 失败, 1 错误 - 修复后: 297 通过, 9 失败, 1 错误 剩余9个失败为待实现的功能增强(验证器模板变量验证)
78 lines
2.4 KiB
Python
78 lines
2.4 KiB
Python
"""
|
||
验证结果数据结构
|
||
|
||
定义验证问题和验证结果的数据类。
|
||
"""
|
||
|
||
from dataclasses import dataclass, field
|
||
from typing import List
|
||
|
||
|
||
@dataclass
|
||
class ValidationIssue:
|
||
"""验证问题"""
|
||
|
||
level: str # "ERROR" | "WARNING" | "INFO"
|
||
message: str
|
||
location: str # "幻灯片 2, 元素 3"
|
||
code: str # "ELEMENT_OUT_OF_BOUNDS"
|
||
|
||
|
||
@dataclass
|
||
class ValidationResult:
|
||
"""验证结果"""
|
||
|
||
valid: bool # 是否有 ERROR
|
||
errors: List[ValidationIssue] = field(default_factory=list)
|
||
warnings: List[ValidationIssue] = field(default_factory=list)
|
||
infos: List[ValidationIssue] = field(default_factory=list)
|
||
|
||
def has_errors(self) -> bool:
|
||
"""是否有错误"""
|
||
return len(self.errors) > 0
|
||
|
||
def format_output(self) -> str:
|
||
"""格式化为命令行输出"""
|
||
lines = []
|
||
|
||
lines.append("🔍 正在检查 YAML 文件...\n")
|
||
|
||
# 错误
|
||
if self.errors:
|
||
lines.append(f"❌ 错误 ({len(self.errors)}):")
|
||
for issue in self.errors:
|
||
location_str = f"[{issue.location}] " if issue.location else ""
|
||
lines.append(f" {location_str}{issue.message}")
|
||
lines.append("")
|
||
|
||
# 警告
|
||
if self.warnings:
|
||
lines.append(f"⚠️ 警告 ({len(self.warnings)}):")
|
||
for issue in self.warnings:
|
||
location_str = f"[{issue.location}] " if issue.location else ""
|
||
lines.append(f" {location_str}{issue.message}")
|
||
lines.append("")
|
||
|
||
# 提示
|
||
if self.infos:
|
||
lines.append(f"ℹ️ 提示 ({len(self.infos)}):")
|
||
for issue in self.infos:
|
||
location_str = f"[{issue.location}] " if issue.location else ""
|
||
lines.append(f" {location_str}{issue.message}")
|
||
lines.append("")
|
||
|
||
# 总结
|
||
if not self.errors and not self.warnings and not self.infos:
|
||
lines.append("验证通过,未发现问题")
|
||
else:
|
||
summary_parts = []
|
||
if self.errors:
|
||
summary_parts.append(f"{len(self.errors)} 个错误")
|
||
if self.warnings:
|
||
summary_parts.append(f"{len(self.warnings)} 个警告")
|
||
if self.infos:
|
||
summary_parts.append(f"{len(self.infos)} 个提示")
|
||
lines.append(f"检查完成: 发现 {', '.join(summary_parts)}")
|
||
|
||
return "\n".join(lines)
|