Overview
CareSupport uses pytest for testing with 88+ structural integrity checks that verify the system without running business logic. Tests are deterministic, fast, and require no network or environment setup.Test Philosophy
Structural over behavioral. Tests verify wiring, config compliance, and enforcement layer correctness rather than simulating full message flows. This catches integration mistakes early without complex mocking. The questions these tests answer:- Does every runtime script import from
config.py(no hardcoded paths)? - Does the handler call
role_filterbefore every send? - Does the handler call
phi_auditfor every interaction? - Does
AGENTS.mdaccurately reflect the current directory structure? - Are all enforcement modules wired into the handler?
- Do all Python files parse without syntax errors?
Test Suites
Structural Tests
Location:runtime/tests/test_structural.py
The core test suite that validates system integrity:
CHECK 1: No Hardcoded Paths
CHECK 1: No Hardcoded Paths
Verifies all runtime scripts use Tests:
config.py instead of hardcoded absolute paths.test_no_hardcoded_paths()- scans for/work/,/__modal/,/home/patternstest_handler_imports_config()- verifiessms_handler.pyimports from config
CHECK 2: Role Filter Before Send
CHECK 2: Role Filter Before Send
Verifies the handler calls Tests:
role_filter to pre-filter context by access level BEFORE the AI call.test_handler_pre_filter_before_ai()- verifies pre-filter runs before AItest_handler_post_check_gates_response()- verifies post-check blocks leakage
CHECK 3: PHI Audit Completeness
CHECK 3: PHI Audit Completeness
Verifies PHI audit logging covers ALL interaction paths.Four audit paths:
log_context_load- member accessed family contextlog_response_sent- outbound message sentlog_response_blocked- leakage detected, response blockedlog_unknown_number- unknown phone number (early return)
test_handler_phi_audit_completeness()- all four paths present
CHECK 4-7: Enforcement & Coverage
CHECK 4-7: Enforcement & Coverage
- All enforcement modules exist (
role_filter,phi_audit,family_editor,approval_pipeline,message_lock) - Handler imports all enforcement modules
- Every enforcement module has test coverage
- Cron scripts (heartbeat, maintenance) have tests
CHECK 8-11: Documentation & Dependency Hygiene
CHECK 8-11: Documentation & Dependency Hygiene
AGENTS.mdreflects current structure- Quality docs exist and are non-trivial
- Approval decisions are mechanical (not agent-driven)
- No circular imports between enforcement modules
- Handler enforcement order correct
Enforcement Tests
runtime/tests/fixtures.py:
- Complete test family (Moreno family)
- Members at every access level
- Phone routing examples
Integration Tests
Cron Tests
Running Tests
Quick Start
Navigate to runtime directory
runtime/ directory with PYTHONPATH=.Common Test Commands
Dry-Run Mode
Test the SMS handler without sending messages:- Processes message through full enforcement pipeline
- Generates AI response
- Does NOT send message via Linq/Twilio
- Logs all enforcement checks
- Shows which model tier was used
Test Data
The test suite uses fixtures inruntime/tests/fixtures.py:
- Full access - care recipient + family caregiver
- Schedule + meds - professional caregiver
- Schedule only - community supporter
CI Integration
Tests are designed for CI environments:- No network calls (all enforcement is local)
- No environment variables required (uses test fixtures)
- Deterministic (same input → same output)
- Fast (runs in less than 5 seconds)
Writing New Tests
Example: Testing a New Enforcement Module
Add to Structural Tests
If adding a new enforcement module, updatetest_structural.py:
Debugging Test Failures
Check the source file
The test tells you which file to check:Fix: Add the import to
runtime/scripts/sms_handler.pyRelated
- Scripts Reference - Runtime scripts tested by these suites
- Project Structure - Directory layout and key files
- Enforcement Layer - Safety gates verified by tests