Testing¶
Objectives¶
- Prevent regressions for existing users.
- Validate new behavior before merge/release.
- Keep local feedback loops fast.
Test layers¶
- Unit tests (
tests/) - CLI command behavior
- config/registry utilities
- chart/template/replacement behavior
- property-based invariants for data transforms/formatting edge cases
- Integration tests (
@pytest.mark.integration) - cross-module workflows with controlled fixtures/mocks
- End-to-end tests (
@pytest.mark.e2e) - full
validate -> buildpaths on representative configs - Live Google Slides tests (
@pytest.mark.live_google,tests/live_tests/) - creates real template presentations via Google API
- copies template into a new deck during render
- inserts real charts across full coverage:
- all built-in template charts
- direct
plotly_gocharts customchart functions from registry
- verifies live replacements and function-driven behavior:
- static text replacement
- dynamic
value_fnreplacement ai_textreplacement via deterministic provider function- table replacement placeholders
- verifies image elements and placeholder replacement in rendered slides
- trashes created files on teardown
- Live Google Docs tests (
@pytest.mark.live_google_docs,tests/live_tests/) - creates real template documents via Google API
- copies template into a new doc during render
- validates marker-scoped replacements (
slide.id->{{SECTION:<id>}}) - validates inline chart insertion in rendered docs
- validates deterministic AI and table replacement behavior
- trashes created files on teardown
- Live Google Sheets tests (
@pytest.mark.live_google_sheets,tests/live_tests/) - creates a real workbook via Google Sheets API
- validates replace-mode writes for current snapshot tabs
- validates append-mode idempotency using
_slideflow_metarun-key tracking - verifies rerun skip behavior prevents duplicate appended rows
- trashes created files on teardown
Local commands¶
uv sync --extra dev --extra ai --locked
source .venv/bin/activate
uv lock --check
uv pip check
uvx --from black==26.3.1 black --check slideflow tests scripts
python -m ruff check slideflow tests scripts
python -m mypy slideflow
pytest -q
pytest -q --cov=slideflow --cov-branch --cov-report=term --cov-report=xml
Run only integration or e2e groups:
Mirror CI marker split locally:
pytest -q -m "not integration and not e2e" --cov=slideflow --cov-branch --cov-report=term --cov-report=xml --cov-fail-under=82
pytest -q -m integration
pytest -q -m e2e
Run live template + chart rendering tests locally:
export SLIDEFLOW_RUN_LIVE=1
export GOOGLE_SLIDEFLOW_CREDENTIALS=/absolute/path/to/service-account.json
export SLIDEFLOW_LIVE_PRESENTATION_FOLDER_ID=<drive-folder-id>
# optional override for chart image uploads:
export SLIDEFLOW_LIVE_DRIVE_FOLDER_ID=<drive-folder-id>
# optional template to copy before test mutations:
export SLIDEFLOW_LIVE_TEMPLATE_ID=<google-slides-template-id>
# optional comma-separated emails to share rendered deck with:
export SLIDEFLOW_LIVE_SHARE_EMAIL=<you@example.com>
# optional permission role for shared deck (reader|writer|commenter):
export SLIDEFLOW_LIVE_SHARE_ROLE=reader
# optional retention toggle; defaults to 1 when sharing is enabled:
export SLIDEFLOW_LIVE_KEEP_ARTIFACTS=1
pytest -q tests/live_tests -m live_google
When SLIDEFLOW_LIVE_SHARE_EMAIL is set, the rendered presentation is shared using the service account and the test prints the deck URL. Artifacts are retained by default in that mode so you can validate the slides visually.
Run live Google Docs tests locally:
export SLIDEFLOW_RUN_LIVE=1
export GOOGLE_DOCS_CREDENTIALS=/absolute/path/to/service-account.json
export SLIDEFLOW_LIVE_DOCUMENT_FOLDER_ID=<drive-folder-id>
# optional override for chart image uploads:
export SLIDEFLOW_LIVE_DRIVE_FOLDER_ID=<drive-folder-id>
# optional seed template document:
export SLIDEFLOW_LIVE_DOC_TEMPLATE_ID=<google-docs-template-id>
# optional comma-separated emails to share rendered doc with:
export SLIDEFLOW_LIVE_SHARE_EMAIL=<you@example.com>
# optional permission role for shared doc (reader|writer|commenter):
export SLIDEFLOW_LIVE_SHARE_ROLE=reader
# optional retention toggle; defaults to 1 when sharing is enabled:
export SLIDEFLOW_LIVE_KEEP_ARTIFACTS=1
pytest -q tests/live_tests -m live_google_docs
Run live Google Sheets tests locally:
export SLIDEFLOW_RUN_LIVE=1
export GOOGLE_SHEETS_CREDENTIALS=/absolute/path/to/service-account.json
export SLIDEFLOW_LIVE_SHEETS_FOLDER_ID=<drive-folder-id>
# optional override:
export SLIDEFLOW_LIVE_DRIVE_FOLDER_ID=<drive-folder-id>
# optional comma-separated emails to share rendered workbook with:
export SLIDEFLOW_LIVE_SHARE_EMAIL=<you@example.com>
# optional permission role for shared workbook (reader|writer|commenter):
export SLIDEFLOW_LIVE_SHARE_ROLE=reader
# optional retention toggle; defaults to 1 when sharing is enabled:
export SLIDEFLOW_LIVE_KEEP_ARTIFACTS=1
pytest -q tests/live_tests -m live_google_sheets
CI quality gates¶
- CI enforces version consistency checks.
- CI enforces dependency consistency via
uv lock --checkanduv pip check. - CI enforces branch-aware coverage floor (
--cov-branch --cov-fail-under=82) on unit tests (not integration and not e2e). - Coverage gate ratchet policy:
- current:
82 - next staged target:
85after planned test-hardening work lands (roadmap items#196/#197) - thresholds should only increase; decreases require explicit maintainer approval
- CI runs dedicated integration and e2e marker suites in separate steps.
- Distribution artifacts are built for every CI run.
- Live Google Slides tests run in a separate workflow (
Live Google Slides) so PR CI remains deterministic. - Live Google Docs tests run in a separate workflow (
Live Google Docs) so PR CI remains deterministic. - Live Google Sheets tests run in a separate workflow (
Live Google Sheets) so PR CI remains deterministic.
Orchestrated runtime note¶
- Chart image export runs through headless Kaleido.
- For Cloud Run/Databricks/self-hosted runners, ensure a Chrome/Chromium binary is available in the runtime image.
- On macOS local runs, if desktop Chrome still steals focus, set
CHROME_PATHorGOOGLE_CHROME_BINto a dedicated Chromium/Chrome-for-Testing binary instead of/Applications/Google Chrome.app/....
Compatibility matrix¶
Compatibility tests assert support remains in place for:
- CLI commands/options (
slideflow build,slideflow validate) - connectors (
csv,json,databricks,duckdb,dbt,databricks_dbt) - replacements (
text,table,ai_text) - charts (
plotly_go,custom,template) - template/registry loading paths
Contribution expectations¶
- Every bug fix should include a regression test.
- Every behavior change should update docs and tests in the same PR.
- Release branches should not introduce untested logic.