7.6 KiB
Test Suite Analysis
Overview
Total Test Files: 43 Total Tests: ~650 Test Collection Status: ✅ All tests collect successfully
Test Categories
1. ✅ Proper Unit Tests (Core Business Logic)
These test pure logic with no external dependencies. Good unit tests!
| File | Tests | Description |
|---|---|---|
test_alignment.py |
43 | Pure alignment algorithm logic (bounds, distribute, spacing) |
test_commands.py |
39 | Command pattern implementation (with mocks) |
test_snapping.py |
30 | Snapping algorithm logic |
test_page_layout.py |
28 | Layout management logic |
test_models.py |
27 | Data model serialization/deserialization |
test_zorder.py |
18 | Z-order management logic |
test_project.py |
21 | Project lifecycle operations |
test_project_serialization.py |
21 | Serialization correctness |
test_rotation_serialization.py |
8 | Rotation data handling |
test_merge.py |
3 | Merge conflict resolution logic |
Total: ~258 tests Status: ✅ These are good unit tests!
2. ⚠️ Integration Tests with Mocks (UI Components)
These test Qt widgets/mixins with mocked dependencies. Somewhat integration-y but still automated.
| File | Tests | Description |
|---|---|---|
test_template_manager.py |
35 | Template management with Qt |
test_base_mixin.py |
31 | Application state mixin (Qt + mocks) |
test_view_ops_mixin.py |
29 | View operations mixin (Qt + mocks) |
test_element_selection_mixin.py |
26 | Selection handling (Qt + mocks) |
test_viewport_mixin.py |
23 | Viewport rendering (Qt + mocks) |
test_page_renderer.py |
22 | Page rendering logic |
test_interaction_undo_mixin.py |
22 | Undo/redo system (Qt + mocks) |
test_edit_ops_mixin.py |
19 | Edit operations (Qt + mocks) |
test_mouse_interaction_mixin.py |
18 | Mouse event handling (Qt + mocks) |
test_gl_widget_integration.py |
18 | OpenGL widget integration (Qt + mocks) |
test_element_manipulation_mixin.py |
18 | Element manipulation (Qt + mocks) |
test_zorder_ops_mixin.py |
17 | Z-order operations mixin (Qt + mocks) |
test_page_ops_mixin.py |
17 | Page operations mixin (Qt + mocks) |
test_page_navigation_mixin.py |
16 | Page navigation (Qt + mocks) |
test_size_ops_mixin.py |
14 | Size operations mixin (Qt + mocks) |
test_pdf_export.py |
13 | PDF export functionality |
test_image_pan_mixin.py |
12 | Image panning (Qt + mocks) |
test_alignment_ops_mixin.py |
12 | Alignment ops mixin (Qt + mocks) |
test_embedded_templates.py |
11 | Template embedding |
test_element_ops_mixin.py |
11 | Element operations (Qt + mocks) |
test_asset_drop_mixin.py |
11 | Drag & drop handling (Qt + mocks) |
test_distribution_ops_mixin.py |
7 | Distribution operations (Qt + mocks) |
test_multiselect.py |
2 | Multi-selection (Qt + mocks) |
test_loading_widget.py |
2 | Loading UI widget (Qt) |
Total: ~405 tests Status: ⚠️ Proper tests but integration-heavy (Qt widgets)
3. ❌ Not Really Tests (Manual/Interactive Tests)
These are scripts that were dumped into the test directory but aren't proper automated tests:
| File | Tests | Type | Issue |
|---|---|---|---|
test_drop_bug.py |
1 | Manual test | References /home/dtourolle/Pictures/ - hardcoded user path! |
test_async_nonblocking.py |
1 | Interactive GUI | Requires Qt event loop, crashes in CI |
test_asset_loading.py |
1 | Manual test | Requires /home/dtourolle/Nextcloud/Photo Gallery/gr58/Album_pytool.ppz |
test_album6_compatibility.py |
1 | Manual test | Requires /home/dtourolle/Nextcloud/Photo Gallery/gr58/Album6.ppz |
test_version_roundtrip.py |
1 | Demo script | Just converted to proper test - now OK! |
test_page_setup.py |
1 | Interactive | Requires Qt window |
test_migration.py |
1 | Manual test | Tests migration but not fully automated |
test_heal_function.py |
1 | Manual test | Interactive asset healing |
test_zip_embedding.py |
1 | Demo script | Content embedding demo |
Total: 9 "tests" Status: ❌ These should be:
- Moved to
examples/orscripts/directory, OR - Converted to proper automated tests with fixtures/mocks
4. 🔧 Test Infrastructure
| File | Purpose |
|---|---|
test_gl_widget_fixtures.py |
Pytest fixtures for OpenGL testing (0 tests, just fixtures) |
Problems Found
🔴 Critical Issues
-
Hardcoded absolute paths in tests:
test_drop_bug.py:/home/dtourolle/Pictures/some_photo.jpgtest_asset_loading.py:/home/dtourolle/Nextcloud/Photo Gallery/gr58/Album_pytool.ppztest_album6_compatibility.py:/home/dtourolle/Nextcloud/Photo Gallery/gr58/Album6.ppz
-
Interactive tests in CI:
test_async_nonblocking.py- Creates Qt application and runs event looptest_page_setup.py- Interactive GUI windowtest_loading_widget.py- Interactive loading widget
-
API mismatch (FIXED):
- ✅
test_version_roundtrip.py- Was using oldload_from_zip()API - ✅
test_asset_loading.py- Was using oldload_from_zip()API
- ✅
🟡 Medium Issues
- Tests that look like demos:
test_heal_function.py- Prints results but doesn't assert muchtest_zip_embedding.py- More of a demo than a testtest_migration.py- Tests migration but could be more thorough
🟢 Minor Issues
- Test file naming:
- Some files have generic names like
test_multiselect.py(2 tests) - Could be more descriptive
- Some files have generic names like
Recommendations
Short Term (Fix Immediately)
-
Mark problematic tests to skip on CI:
@pytest.mark.skip(reason="Requires user-specific files") def test_album6_compatibility(): ... -
Add skip conditions for missing files:
@pytest.mark.skipif(not os.path.exists(TEST_FILE), reason="Test file not found") -
Fix the crashing test:
test_async_nonblocking.pyneeds@pytest.mark.guior similar- Or mark as
@pytest.mark.skipfor now
Medium Term (Cleanup)
-
Move non-tests out of tests directory:
tests/ → Keep only real automated tests examples/ → Move interactive demos here scripts/ → Move manual test scripts here -
Create proper fixtures for file-based tests:
- Use
pytest.fixtureto create temporary test files - Don't rely on user's home directory
- Use
-
Add proper test markers:
@pytest.mark.unit # Pure logic, no dependencies @pytest.mark.integration # Needs Qt, database, etc. @pytest.mark.slow # Takes >1 second @pytest.mark.gui # Needs display/X server
Long Term (Architecture)
-
Separate test types:
tests/unit/ # Pure unit tests (fast, no deps) tests/integration/ # Integration tests (Qt, mocks) tests/e2e/ # End-to-end tests (slow, full stack) -
Add CI configuration:
# Run fast unit tests on every commit # Run integration tests on PR # Run GUI tests manually only
Summary
| Category | Count | Quality |
|---|---|---|
| ✅ Good Unit Tests | ~258 | Excellent |
| ⚠️ Integration Tests | ~405 | Good (but heavy) |
| ❌ Not Real Tests | ~9 | Need fixing |
| 🔧 Infrastructure | 1 | Good |
| Total | ~673 | Mixed |
Bottom Line:
- ~66% of tests are solid (unit + integration with mocks)
- ~34% are integration tests that rely heavily on Qt
- ~1.3% are broken/manual tests that need cleanup
The test suite is generally good, but needs cleanup of the manual/interactive tests that were dumped into the tests directory.