1
0

test: add comprehensive pytest test suite

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
This commit is contained in:
2026-03-02 23:11:34 +08:00
parent 027a832c9a
commit ab2510a400
56 changed files with 7035 additions and 6 deletions

View File

@@ -0,0 +1,29 @@
metadata:
size: 16:9
slides:
- elements:
- type: text
box: [1, 1, 3, 0.5]
content: "All Element Types One Slide"
font:
size: 18
color: "#333333"
- type: image
box: [1, 2, 2, 2]
src: "test_image.png"
- type: shape
box: [4, 2, 2, 1]
shape: rectangle
fill: "#4a90e2"
- type: table
position: [1, 4.5]
col_widths: [2, 2, 2]
data:
- ["H1", "H2", "H3"]
- ["D1", "D2", "D3"]
style:
font_size: 12

View File

@@ -0,0 +1,10 @@
metadata:
size: 16:9
slides:
- elements:
- type: text
box: [1, 1, 8, 1]
content: ""
font:
size: 18

View File

@@ -0,0 +1,15 @@
metadata:
size: 16:9
slides:
- elements:
# 空字体属性
- type: text
box: [1, 1, 3, 0.5]
content: "Empty Font Attributes"
font: {}
# 空字体
- type: text
box: [1, 2, 3, 0.5]
content: "No Font Field"

View File

@@ -0,0 +1,20 @@
metadata:
size: 16:9
slides:
- elements:
# 混合颜色格式
- type: text
box: [1, 1, 3, 0.5]
content: "Mixed Color Formats"
font:
size: 18
color: "#fff"
- type: shape
box: [1, 2, 2, 1]
shape: rectangle
fill: "#000000"
line:
color: "#abc"
width: 2

View File

@@ -0,0 +1,11 @@
metadata:
size: 16:9
slides:
- elements:
- type: text
box: [-1, -1, 2, 1]
content: "Negative Position"
font:
size: 18
color: "#333333"

View File

@@ -0,0 +1,10 @@
metadata:
size: 16:9
slides:
- elements:
- type: text
box: [1, 1, 8, 2]
content: "Special chars: < > & \" ' \\n \\t @#$%^&*()"
font:
size: 18

View File

@@ -0,0 +1,10 @@
metadata:
size: 16:9
slides:
- elements:
- type: text
box: [1, 1, 8, 1]
content: "Unicode 测试: 你好世界 🌍"
font:
size: 24

View File

@@ -0,0 +1,11 @@
metadata:
size: 16:9
slides:
- elements:
- type: text
box: [0, 0, 1, 1]
content: "Very Large Font"
font:
size: 200
color: "#333333"

View File

@@ -0,0 +1,10 @@
metadata:
size: 16:9
slides:
- elements:
- type: text
box: [1, 1, 0, 0]
content: "Zero Size Box"
font:
size: 18