Skip to main content

Test Coverage Report

Last updated: 2026-02-03 Overall coverage: 21% (4930 statements, 3875 missed)

Executive Summary

The current test suite focuses on Forseti agent business logic (charter validation, category classification) which has excellent coverage (96-100%). UI components and external integrations have minimal coverage, which is expected for a Streamlit-based application.

Coverage by Area

Well Tested (80-100%)

ModuleCoverageNotes
forseti/features/category_classification.py100%Core business logic
forseti/features/charter_validation.py100%Core business logic
agents/forseti/models.py96%Data models
services/__init__.py100%Service exports
services/logging/config.py88%Logging configuration
prompts/constants.py100%Static definitions

Partially Tested (20-79%)

ModuleCoveragePriorityNotes
agents/base.py52%MediumBase agent class
agents/forseti/features/base.py80%LowFeature base class
processors/workflows/workflow_autocontribution.py72%MediumAuto-contribution flow
services/logging/domains.py57%LowDomain loggers
providers/base.py71%MediumProvider base class
providers/config.py84%LowProvider configuration

Not Tested (0%)

ModuleCoveragePriorityReason
Streamlit UI
front.py0%LowUI - requires E2E testing
sidebar.py0%LowUI - requires E2E testing
admin/scheduler_dashboard.py0%LowUI - requires E2E testing
auto_contribution/views.py0%LowUI - requires E2E testing
mockup/batch_view.py0%LowUI - requires E2E testing
Scheduler/Tasks
services/scheduler/__init__.py0%HighNew code, needs tests
services/scheduler/utils.py0%HighNew code, needs tests
services/tasks/__init__.py0%HighTask boilerplate
services/tasks/task_contributions_analysis.py0%HighCore task
services/tasks/task_firecrawl.py0%MediumStub implementation
services/tasks/task_opik_experiment.py0%MediumStub implementation
API
api/routes/validate.py0%MediumFastAPI routes
main.py0%LowApp entry point
Auth
auth.py0%MediumAuthentication

Improvement Priorities

Priority 1: Scheduler & Tasks (High Impact)

The scheduler system is new and has no tests. These are critical for reliability:

tests/unit/services/
├── scheduler/
│ ├── test_scheduler_init.py # Scheduler startup, job registration
│ └── test_scheduler_utils.py # Redis helpers, key management
└── tasks/
├── test_task_boilerplate.py # Lock acquisition, success keys
└── test_task_contributions.py # Contributions analysis logic

Key test scenarios:

  • Lock acquisition and release
  • Success key prevents duplicate runs
  • Task skipping on already completed
  • Provider failover logic
  • Error handling and recovery

Priority 2: Provider Testing (Medium Impact)

Providers have 16-20% coverage. Focus on error handling:

# tests/unit/providers/test_provider_errors.py
class TestProviderErrorHandling:
def test_rate_limit_detection(self):
"""Verify rate limit errors are correctly identified."""

def test_api_key_missing(self):
"""Verify clear error when API key not configured."""

def test_timeout_handling(self):
"""Verify timeout errors don't crash the app."""

Priority 3: API Routes (Medium Impact)

The FastAPI validation endpoint needs testing:

# tests/integration/test_api_validate.py
class TestValidateEndpoint:
def test_validate_contribution_success(self):
"""POST /api/validate returns validation result."""

def test_validate_missing_fields(self):
"""Returns 400 on missing required fields."""

Not Worth Testing (Low ROI)

ModuleReason
Streamlit UI (front.py, sidebar.py, etc.)Requires Selenium/Playwright E2E tests. Manual testing is more practical for now.
main.pyEntry point, tested implicitly
Translation loading (i18n.py)Simple JSON loading, low risk
Static configurationsNo logic to test

Coverage Goals

TimeframeTargetFocus Areas
Short-term30%Scheduler, Tasks, Provider error handling
Medium-term45%API routes, Workflow processors
Long-term60%E2E tests with Playwright for critical flows

Running Coverage

# Generate coverage report
poetry run pytest --cov=app --cov-report=term-missing

# Generate HTML report
poetry run pytest --cov=app --cov-report=html
# Open htmlcov/index.html

# Coverage for specific module
poetry run pytest --cov=app/services/scheduler --cov-report=term-missing

# Fail if coverage below threshold
poetry run pytest --cov=app --cov-fail-under=25

Test File Locations

tests/
├── conftest.py # Shared fixtures
├── test_autocontribution_integration.py # Auto-contribution tests
├── test_contribution_assistant.py # Draft generation tests
├── integration/
│ └── test_n8n_integration.py # N8N webhook tests
└── unit/
└── forseti/
├── test_batch_validation.py # Batch processing
├── test_category_classification.py # Category tests (100%)
└── test_charter_validation.py # Charter tests (100%)
tests/
├── unit/
│ ├── services/
│ │ ├── scheduler/
│ │ │ ├── __init__.py
│ │ │ ├── test_scheduler_init.py
│ │ │ └── test_scheduler_utils.py
│ │ └── tasks/
│ │ ├── __init__.py
│ │ ├── test_task_boilerplate.py
│ │ └── test_task_contributions.py
│ └── providers/
│ ├── __init__.py
│ ├── test_provider_base.py
│ └── test_provider_errors.py
└── integration/
├── test_api_validate.py
└── test_redis_storage.py

CI Integration

Add coverage check to CI pipeline:

# .github/workflows/test.yml
- name: Run tests with coverage
run: poetry run pytest --cov=app --cov-fail-under=25 --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml