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:
29
tests/fixtures/yaml_samples/edge_cases/all_element_types_one_slide.yaml
vendored
Normal file
29
tests/fixtures/yaml_samples/edge_cases/all_element_types_one_slide.yaml
vendored
Normal 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
|
||||
10
tests/fixtures/yaml_samples/edge_cases/empty_content.yaml
vendored
Normal file
10
tests/fixtures/yaml_samples/edge_cases/empty_content.yaml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
metadata:
|
||||
size: 16:9
|
||||
|
||||
slides:
|
||||
- elements:
|
||||
- type: text
|
||||
box: [1, 1, 8, 1]
|
||||
content: ""
|
||||
font:
|
||||
size: 18
|
||||
15
tests/fixtures/yaml_samples/edge_cases/empty_font_attributes.yaml
vendored
Normal file
15
tests/fixtures/yaml_samples/edge_cases/empty_font_attributes.yaml
vendored
Normal 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"
|
||||
20
tests/fixtures/yaml_samples/edge_cases/mixed_color_formats.yaml
vendored
Normal file
20
tests/fixtures/yaml_samples/edge_cases/mixed_color_formats.yaml
vendored
Normal 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
|
||||
11
tests/fixtures/yaml_samples/edge_cases/negative_position.yaml
vendored
Normal file
11
tests/fixtures/yaml_samples/edge_cases/negative_position.yaml
vendored
Normal 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"
|
||||
10
tests/fixtures/yaml_samples/edge_cases/special_chars.yaml
vendored
Normal file
10
tests/fixtures/yaml_samples/edge_cases/special_chars.yaml
vendored
Normal 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
|
||||
10
tests/fixtures/yaml_samples/edge_cases/unicode.yaml
vendored
Normal file
10
tests/fixtures/yaml_samples/edge_cases/unicode.yaml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
metadata:
|
||||
size: 16:9
|
||||
|
||||
slides:
|
||||
- elements:
|
||||
- type: text
|
||||
box: [1, 1, 8, 1]
|
||||
content: "Unicode 测试: 你好世界 🌍"
|
||||
font:
|
||||
size: 24
|
||||
11
tests/fixtures/yaml_samples/edge_cases/very_large_font.yaml
vendored
Normal file
11
tests/fixtures/yaml_samples/edge_cases/very_large_font.yaml
vendored
Normal 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"
|
||||
10
tests/fixtures/yaml_samples/edge_cases/zero_size_box.yaml
vendored
Normal file
10
tests/fixtures/yaml_samples/edge_cases/zero_size_box.yaml
vendored
Normal 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
|
||||
Reference in New Issue
Block a user