Skip to content

Testing Reference

Complete reference for the IDX API pytest testing framework.

The Makefile provides several targets for different testing scenarios:

CommandDescriptionUse Case
make testRun all tests with coverageDefault test run
make test-fastRun tests without coverageQuick iteration during development
make test-htmlGenerate HTML reportsFull reports with coverage
make test-watchAuto-run on file changesActive development
CommandDescription
make test-authAuthentication tests only
make test-unitUnit tests in tests/unit/
make test-integrationIntegration tests
CommandDescription
make publish-docsCopy reports to docs site
make test-publishRun tests + publish reports
idx-api/
├── tests/
│ ├── conftest.py # Shared fixtures
│ ├── test_health.py # Health check tests
│ ├── test_auth.py # Authentication tests
│ ├── test_agents.py # Agent CRUD tests
│ ├── unit/ # Unit tests (isolated)
│ └── integration/ # Integration tests
├── reports/
│ ├── html/
│ │ └── report.html # pytest HTML report
│ └── coverage/
│ └── index.html # Coverage report
└── Makefile

Use pytest markers to categorize tests:

import pytest
@pytest.mark.auth
def test_api_key_validation():
"""Tests marked with @pytest.mark.auth"""
pass
@pytest.mark.integration
def test_database_operations():
"""Tests that require full stack"""
pass
@pytest.mark.slow
def test_embedding_generation():
"""Tests that take longer to run"""
pass

Run specific markers:

Terminal window
uv run pytest -m auth # Only auth tests
uv run pytest -m "not slow" # Skip slow tests

The conftest.py file provides shared fixtures for all tests:

@pytest.fixture
def db_session():
"""Create isolated test database session."""
engine = create_engine("sqlite:///:memory:")
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine)
session = Session()
yield session
session.close()

Tests use pytest with the following plugins:

  • pytest-asyncio - Async test support for FastAPI
  • pytest-html - HTML report generation
  • pytest-cov - Coverage measurement

Configuration in pyproject.toml:

[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]

From the project root:

Terminal window
# Run tests in Docker container
make test-docker
# Run tests and publish to docs site
make docs-publish
# Build docs image with embedded reports
make docs-build

The idx-api-test service runs tests in an isolated container:

Terminal window
# Run tests with the test profile
docker compose --profile test run --rm idx-api-test
# View test reports in docs dev server
docker compose --profile dev up idx-docs-dev
# Reports available at: https://help.{DOMAIN}/reports/tests/report.html

Test reports are stored in a Docker volume called test-reports:

  • idx-api-test: Writes reports to /app/reports → volume
  • idx-docs-dev: Mounts volume at /app/public/reports (read-only)

This allows the docs dev server to serve the latest reports without rebuilding.