-
-
Notifications
You must be signed in to change notification settings - Fork 307
Testing Overview
Welcome to the Calibre-Web Automated (CWA) testing documentation! This page provides an overview of the test suite and links to detailed guides.
- Quick Start Guide - Get up and running with tests in 5 minutes
- Running Tests - Interactive test runner and execution modes
- Docker-in-Docker Mode - Testing inside dev containers
- Writing Tests - Comprehensive guide for contributors
- Implementation Status - What's done and what's planned
CWA is a complex application with:
- Multiple background services (s6-overlay)
- Three separate SQLite databases
- 27+ ebook import formats
- Docker deployment across different architectures
- Integration with Calibre CLI tools
Automated tests help us:
- ✅ Catch bugs before they reach users
- ✅ Prevent regressions when adding new features
- ✅ Give contributors confidence their changes work
- ✅ Speed up the review process
- ✅ Serve as living documentation
| Category | Tests | Status | Coverage |
|---|---|---|---|
| Smoke Tests | 13 | ✅ Passing | Critical paths |
| Unit Tests | 83 | ✅ Passing | Core utilities |
| Docker Tests | 9 | ✅ Passing | Container health |
| Integration Tests | 20 | ✅ Passing | Workflows |
| Total | 125+ | ✅ Working | ~30% |
CWA supports two testing modes:
1. Bind Mount Mode (Default)
- Used by CI/CD (GitHub Actions)
- Fast and reliable
- Works on host systems
- Result: 25/25 integration tests passing
2. Docker Volume Mode
- For development containers (Docker-in-Docker)
- Automatic volume management
- Handles bind mount limitations
- Result: 19/20 tests passing (1 documented skip)
The easiest way to run tests:
./run_tests.shThis gives you a friendly menu with 7 options:
- Integration Tests (Bind Mount)
- Integration Tests (Docker Volume)
- Docker Startup Tests
- All Tests
- Quick Test (30 seconds)
- Custom Selection
- Info & Status
Quick verification:
pytest tests/smoke/ -v # 30 secondsFull integration suite:
pytest tests/integration/ -v # 3-4 minutesIn a dev container:
USE_DOCKER_VOLUMES=true pytest tests/integration/ -vPurpose: Verify basic functionality isn't broken
Duration: <30 seconds
Run: Every commit
Tests critical paths like:
- App starts successfully
- Databases are accessible
- Required binaries exist
- Config loads correctly
Purpose: Test individual functions in isolation
Duration: ~2 minutes
Run: Every commit
Tests components like:
- Database operations (CWA_DB)
- Helper functions
- File validation
- Format detection
Purpose: Verify container health
Duration: ~1 minute
Run: Pre-merge
Tests Docker-specific behavior:
- Container starts successfully
- Services are running
- Health checks pass
- Volumes mounted correctly
Purpose: Test multi-component workflows
Duration: ~3-4 minutes
Run: Pre-merge
Tests complete workflows:
- Book import pipeline
- File conversion
- Metadata enforcement
- EPUB fixing
- Database tracking
Minimal requirements:
- Python 3.8+
- Docker (for integration tests)
- Bash shell
Test dependencies:
pip install -r requirements-dev.txtThe interactive test runner will auto-install pytest if needed.
- Color-coded output - Easy to read results
- Auto-detection - Chooses right mode for your environment
- Progress indicators - Know what's happening
- Error handling - Clear error messages with fixes
- Menu-driven - No need to remember commands
- Transparent switching - Single environment variable toggles modes
- CI optimized - Bind mounts for maximum speed
- DinD compatible - Docker volumes when needed
- Zero conflicts - Modes don't interfere with each other
- Log polling - Detects when container is ready (~12s vs 60s)
- Auto-cleanup - Removes containers after tests
- Volume management - Creates and destroys test volumes
- Error recovery - Handles container failures gracefully
- Test infrastructure and documentation
- Smoke tests for critical paths
- Unit tests for core utilities (CWA_DB, helper functions)
- Docker container health tests
- Integration tests for ingest pipeline
- Dual-mode architecture (bind mount + Docker volume)
- Interactive test runner script
- Additional unit tests (ingest_processor, cover_enforcer)
- OAuth flow integration tests
- Kobo sync integration tests
- Metadata provider tests
- Sample test fixtures for all formats
- End-to-end workflow tests
- Network share mode tests
- Performance and load tests
- Browser-based UI tests (Playwright)
- Comprehensive CI/CD pipeline
Coverage Goals:
- Week 6: 40% coverage
- Week 12: 60% coverage
- Long term: 70%+ coverage
We welcome test contributions! Tests are one of the most valuable contributions you can make.
Easy first contributions:
- Add unit tests for utility functions
- Add parameterized tests for format detection
- Create minimal sample ebook fixtures
- Improve test documentation
Getting started:
- Read the Testing Guide for Contributors
- Pick an untested area (check coverage report)
- Write tests following our patterns
- Submit a PR
Questions?
- Discord: https://discord.gg/EjgSeek94R
- GitHub Issues: Tag with
testinglabel
- Quick Start Guide - 5-minute setup
- Running Tests - All execution modes
- Docker-in-Docker Mode - Dev container testing
- Writing Tests - Complete guide
- Implementation Status - Progress tracking
-
run_tests.sh- Interactive test runner -
pytest.ini- Test configuration -
requirements-dev.txt- Test dependencies -
tests/conftest.py- Shared fixtures
# Generate coverage report
pytest --cov=cps --cov=scripts --cov-report=html
# View in browser
open htmlcov/index.htmlHappy Testing! 🎉
Every test makes CWA more reliable and easier to maintain. Thank you for contributing!