Add complete test infrastructure for yaml2pptx project with 245+ tests covering unit, integration, and end-to-end scenarios. Test structure: - Unit tests: elements, template system, validators, loaders, utils - Integration tests: presentation and rendering flows - E2E tests: CLI commands (convert, check, preview) Key features: - PptxFileValidator for Level 2 PPTX validation (file structure, element count, content matching, position tolerance) - Comprehensive fixtures for test data consistency - Mock-based testing for external dependencies - Test images generated with PIL/Pillow - Boundary case coverage for edge scenarios Dependencies added: - pytest, pytest-cov, pytest-mock - pillow (for test image generation) Documentation updated: - README.md: test running instructions - README_DEV.md: test development guide Co-authored-by: OpenSpec change: add-comprehensive-tests
76 lines
3.2 KiB
Markdown
76 lines
3.2 KiB
Markdown
## 1. 测试环境配置
|
||
|
||
- [x] 1.1 更新 pyproject.toml 添加测试依赖(pytest、pytest-cov、pytest-mock、pillow)
|
||
- [x] 1.2 创建 tests/conftest.py 配置共享 fixtures
|
||
- [x] 1.3 创建 tests/__init__.py 空文件
|
||
|
||
## 2. 测试基础设施
|
||
|
||
- [x] 2.1 创建 tests/conftest_pptx.py 实现 PptxFileValidator 工具类
|
||
- [x] 2.2 创建 tests/fixtures/ 目录结构
|
||
- [x] 2.3 创建 tests/fixtures/yaml_samples/minimal.yaml 最小示例
|
||
- [x] 2.4 创建 tests/fixtures/yaml_samples/full_features.yaml 完整功能示例
|
||
- [x] 2.5 创建 tests/fixtures/yaml_samples/edge_cases/ 边界情况样本
|
||
- [x] 2.6 创建 tests/fixtures/yaml_samples/invalid/ 无效样本
|
||
- [x] 2.7 创建 tests/fixtures/templates/test_template.yaml 测试模板
|
||
- [x] 2.8 添加创建测试图片的 fixture 函数(已在 conftest.py 中实现)
|
||
|
||
## 3. 单元测试 - 元素类
|
||
|
||
- [x] 3.1 创建 tests/unit/test_elements.py 并实现 TextElement 测试
|
||
- [x] 3.2 实现 ImageElement 测试
|
||
- [x] 3.3 实现 ShapeElement 测试
|
||
- [x] 3.4 实现 TableElement 测试
|
||
- [x] 3.5 实现 create_element() 工厂函数测试
|
||
|
||
## 4. 单元测试 - 模板系统
|
||
|
||
- [x] 4.1 创建 tests/unit/test_template.py 并实现模板初始化测试
|
||
- [x] 4.2 实现变量解析测试(resolve_value、resolve_element)
|
||
- [x] 4.3 实现条件渲染测试(evaluate_condition)
|
||
- [x] 4.4 实现模板渲染测试(render)
|
||
|
||
## 5. 单元测试 - 验证器
|
||
|
||
- [x] 5.1 创建 tests/unit/test_validators/ 目录
|
||
- [x] 5.2 创建 tests/unit/test_validators/test_geometry.py 并实现边界检查测试
|
||
- [x] 5.3 创建 tests/unit/test_validators/test_resource.py 并实现资源验证测试
|
||
- [x] 5.4 创建 tests/unit/test_validators/test_result.py 并实现验证结果测试
|
||
- [x] 5.5 创建 tests/unit/test_validators/test_validator.py 并实现主验证器测试
|
||
|
||
## 6. 单元测试 - 其他模块
|
||
|
||
- [x] 6.1 创建 tests/unit/test_loaders/test_yaml_loader.py 并实现加载测试
|
||
- [x] 6.2 创建 tests/unit/test_utils.py 并实现工具函数测试
|
||
- [x] 6.3 创建 tests/unit/test_validators/__init__.py 空文件
|
||
- [x] 6.4 创建 tests/unit/test_loaders/__init__.py 空文件
|
||
|
||
## 7. 集成测试
|
||
|
||
- [x] 7.1 创建 tests/integration/test_presentation.py 并实现 Presentation 类测试
|
||
- [x] 7.2 创建 tests/integration/test_rendering_flow.py 并实现渲染流程测试
|
||
- [x] 7.3 实现文本元素渲染集成测试
|
||
- [x] 7.4 实现图片元素渲染集成测试
|
||
- [x] 7.5 实现形状元素渲染集成测试
|
||
- [x] 7.6 实现表格元素渲染集成测试
|
||
- [x] 7.7 实现背景渲染集成测试
|
||
- [x] 7.8 创建 tests/integration/test_validation_flow.py 并实现验证流程测试
|
||
|
||
## 8. 端到端测试
|
||
|
||
- [x] 8.1 创建 tests/e2e/test_convert_cmd.py 并实现基本转换测试
|
||
- [x] 8.2 实现自动输出文件名测试
|
||
- [x] 8.3 实现使用模板测试
|
||
- [x] 8.4 实现跳过验证测试
|
||
- [x] 8.5 实现强制覆盖测试
|
||
- [x] 8.6 实现无效输入文件测试
|
||
- [x] 8.7 创建 tests/e2e/test_check_cmd.py 并实现验证通过测试
|
||
- [x] 8.8 实现验证失败测试
|
||
- [x] 8.9 创建 tests/e2e/test_preview_cmd.py 并实现 HTML 生成测试
|
||
|
||
## 9. 文档更新
|
||
|
||
- [x] 9.1 更新 README.md 添加测试运行说明
|
||
- [x] 9.2 更新 README_DEV.md 添加测试开发指南
|
||
- [x] 9.3 在 README.md 中添加测试覆盖率要求说明
|