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
1.5 KiB
1.5 KiB
ADDED Requirements
Requirement: Pytest 测试框架配置
项目 SHALL 使用 pytest 作为测试框架,通过 pyproject.toml 配置测试依赖和运行参数。
Scenario: 配置测试依赖
- WHEN 开发者在 pyproject.toml 中配置测试依赖
- THEN 项目包含 pytest、pytest-cov、pytest-mock 等依赖
Scenario: 运行测试
- WHEN 开发者执行
uv run pytest - THEN 所有测试被发现并执行
Requirement: 共享 Fixtures
测试框架 SHALL 提供 conftest.py 文件,定义所有测试共享的 fixtures。
Scenario: 临时目录 fixture
- WHEN 测试使用
temp_dirfixture - THEN 系统创建一个临时目录并在测试后自动清理
Scenario: 测试 YAML 文件 fixture
- WHEN 测试使用
sample_yamlfixture - THEN 系统创建一个包含最小可用内容的测试 YAML 文件
Scenario: 测试图片 fixture
- WHEN 测试使用
sample_imagefixture - THEN 系统创建一个测试用图片文件
Scenario: 测试模板 fixture
- WHEN 测试使用
sample_templatefixture - THEN 系统创建包含测试模板的目录
Requirement: 临时文件管理
测试生成的临时 PPTX 文件 SHALL 存放在系统临时目录,测试后自动清理。
Scenario: 临时 PPTX 输出目录
- WHEN 测试生成 PPTX 文件
- THEN 文件存放在系统临时目录的 yaml2pptx_tests 子目录下
Scenario: 自动清理
- WHEN 测试运行完成
- THEN 所有生成的 test_*.pptx 文件被删除