-
-
Notifications
You must be signed in to change notification settings - Fork 281
Testing Quick Start
Get up and running with CWA tests in 5 minutes!
# Run the interactive test runner
./run_tests.sh
# Choose option 5 for a quick testThat's it! The script handles everything else.
You need:
- β Docker installed and running
- β Python 3.10+ (3.13 recommended)
- β Bash shell
On macOS/Linux:
# Check Docker
docker --version
# Check Python (3.10 minimum, 3.13 recommended)
python3 --versionOn Windows (WSL2):
# Install WSL2 first, then:
docker --version
python3 --versionVerify everything works:
# Run smoke tests (fast, no Docker needed for most)
pytest tests/smoke/ -vExpected output:
tests/smoke/test_smoke.py::test_python_version PASSED
tests/smoke/test_smoke.py::test_flask_app_can_be_imported PASSED
tests/smoke/test_smoke.py::test_cwa_db_can_be_imported PASSED
...
10 passed, 9 skipped in 2.15s β
Note: Some tests will skip if you're not inside a Docker container - this is normal!
The easiest way to run tests:
./run_tests.shββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CALIBRE-WEB AUTOMATED - TEST RUNNER β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β Environment: host β
β Python: 3.13.0 β
β Docker: Available β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β TEST SUITE OPTIONS β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β 1) Integration Tests (Bind Mount Mode) β
β β Standard mode for local testing (20 tests, ~3-4 min) β
β β
β 2) Integration Tests (Docker Volume Mode) β
β β For dev containers/DinD (19 tests, ~3-4 min) β
β β
β 3) Docker Startup Tests β
β β Container health checks (9 tests, ~1 min) β
β β
β 4) All Tests β
β β Complete test suite (~5-7 min) β
β β
β 5) Quick Test β
β β Fast verification (1 test, ~30 sec) β
β β
β 6) Custom Test Selection β
β β Run specific tests/patterns β
β β
β 7) Show Info β
β β Test environment & documentation β
β β
β q) Quit β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Enter your choice [1-7, q]:
First time? Choose option 5 for a quick test.
Want full test suite? Choose option 1 (standard mode).
In a dev container? Choose option 2 (it may auto-select this).
If you prefer command-line:
# Smoke tests (30 seconds)
pytest tests/smoke/ -v
# Unit tests (2 minutes)
pytest tests/unit/ -v
# Docker tests (1 minute)
pytest tests/docker/ -v
# Integration tests (3-4 minutes)
pytest tests/integration/ -v
# Everything (5-7 minutes)
pytest tests/ -v# Single test file
pytest tests/unit/test_cwa_db.py -v
# Single test function
pytest tests/smoke/test_smoke.py::test_python_version -v
# Tests matching a pattern
pytest -k "database" -v
# Tests in parallel (faster)
pytest tests/unit/ -n autoIf you're running tests inside a Docker container (Docker-in-Docker):
# Set environment variable
export USE_DOCKER_VOLUMES=true
# Run tests
pytest tests/integration/ -vOr use the interactive runner (it auto-detects):
./run_tests.sh
# It will show "Environment: docker" and auto-select volume modetests/integration/test_ingest_pipeline.py::test_ingest_epub_already_target_format PASSED
tests/integration/test_ingest_pipeline.py::test_some_feature FAILED
Check the error message for details.
tests/integration/test_cwa_db_tracks_import SKIPPED (requires config volume)
This is expected in Docker volume mode.
20 passed, 1 skipped in 187.45s
- 20 passed - Tests ran successfully
- 1 skipped - Test was intentionally skipped
- 187.45s - Total duration (~3 minutes)
Once you're comfortable with basic testing:
- Running Tests - All execution modes explained
- Writing Tests - Contribute your own tests
- Docker-in-Docker Mode - Advanced DinD usage
For development:
pip install -r requirements-dev.txtThis installs:
- pytest (test runner)
- pytest-flask (Flask testing)
- pytest-timeout (prevent hanging)
- pytest-mock (mocking utilities)
- faker (test data generation)
See which code is tested:
# Generate HTML coverage report
pytest --cov=cps --cov=scripts --cov-report=html
# Open in browser
open htmlcov/index.html # macOS
xdg-open htmlcov/index.html # LinuxFix: Install Docker Desktop
- macOS/Windows: https://docs.docker.com/desktop/
- Linux: https://docs.docker.com/engine/install/
Fix: Install test dependencies
pip install pytest
# Or install all dev dependencies:
pip install -r requirements-dev.txtFix: Make test runner executable
chmod +x run_tests.shFirst run? Docker needs to download images (~1-2 GB). This happens once.
Subsequent runs should be much faster (3-4 minutes for integration tests).
Speed up tests:
# Run in parallel
pytest tests/unit/ -n auto
# Run only fast tests
pytest -m "not slow" tests/Fix: Check Docker is running
docker psIf Docker isn't running, start Docker Desktop.
While developing, use quick tests:
# Test just what you're working on
pytest tests/unit/test_cwa_db.py::test_specific_function -vAuto-run tests when files change:
pip install pytest-watch
ptw tests/unit/Useful when debugging:
pytest tests/ -x # Stop at first failure
pytest tests/ -vv # Extra verbose outputAfter fixing a bug:
pytest --lf # Run last failed tests onlySeriously, it's easier:
./run_tests.shBefore submitting code:
- Run smoke tests:
pytest tests/smoke/ -v - Run relevant unit tests
- Run integration tests if changing workflows
- All tests pass β
- No new errors or warnings
- Discord: https://discord.gg/EjgSeek94R
-
GitHub Issues: Tag with
testinglabel - Documentation: See Testing Guide for Contributors
You're ready to go! π
Start with the interactive test runner (./run_tests.sh) and explore from there.