Files
brunoandClaude Sonnet 4.5 9b7a0f6ec2 test: add comprehensive risk assessments API test suite (Issue #37)
Created complete test coverage for risk assessment endpoints:
- 25 test cases covering all 3 endpoints
- POST /risk-assessments (11 tests)
- GET /risk-assessments (5 tests)
- GET /risk-assessments/{id} (5 tests)
- Edge cases and error handling (4 tests)

Test features:
✅ Access control (guardian, psychologist, administrator)
✅ Ollama integration (mocked with AsyncMock)
✅ Fallback mechanisms
✅ Pagination and filtering
✅ Error handling and edge cases
✅ Data validation

Dependencies and fixes:
- Updated httpx (0.26.0 → 0.27.2) for pytest-httpx compatibility
- Fixed JWT imports (import jwt → from jose import jwt)
- Fixed Pydantic v2 field_validator syntax
- Fixed model import conflicts (removed duplicate User model)
- Updated backend/models/__init__.py to import left_behind_children models
- Added missing auth exports (blacklist_token, is_token_blacklisted, can_access_risk_assessment)

Known issue (⚠️ BLOCKING):
- SQLite UUID type incompatibility preventing tests from running
- Error: SQLiteTypeCompiler can't render UUID type
- Need to implement UUID-to-String adapter for SQLite in tests
- All 25 tests fail at setup phase

Files created/modified:
- tests/unit/test_api_risk_assessments.py (NEW - 700+ lines)
- requirements.txt (updated httpx, commented safety)
- backend/auth/__init__.py (added exports)
- backend/auth/utils.py (fixed JWT import)
- backend/auth/dependencies.py (fixed JWT import)
- backend/api/data.py (fixed Pydantic validator)
- backend/models/__init__.py (switched to left_behind_children models)

Next steps:
1. Fix UUID/SQLite compatibility (use String(36) or UUID adapter)
2. Run tests successfully
3. Achieve >95% coverage target

Progress: Issue #37 - 70% complete (tests written, need execution)

Related: #38, #39, #40, #41, #42

🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
2026-01-01 14:23:55 +08:00

61 lines
1.2 KiB
Plaintext

# Core Framework
fastapi==0.109.0
uvicorn[standard]==0.27.0
pydantic==2.5.3
pydantic-settings==2.1.0
# Database
sqlalchemy==2.0.25
aiosqlite==0.19.0
alembic==1.13.1
asyncpg==0.29.0 # PostgreSQL async driver
# Redis
redis==5.0.1 # Redis client with async support
# HTTP Client
httpx==0.27.2 # Updated for pytest-httpx compatibility
aiohttp==3.9.1
# Authentication
python-jose[cryptography]==3.3.0
passlib[bcrypt]==1.7.4
python-multipart==0.0.6
# Development Tools
black==24.1.1
flake8==7.0.0
mypy==1.8.0
isort==5.13.2
# Testing
pytest==7.4.4
pytest-asyncio==0.23.3
pytest-cov==4.1.0
pytest-mock==3.12.0
pytest-httpx==0.30.0
pytest-playwright==0.4.4
playwright==1.41.0
faker==22.6.0 # Test data generation
factory-boy==3.3.0 # Test factories
# Code Quality
pylint==3.0.3
bandit==1.7.6
# safety==3.0.1 # Commented out due to pydantic version conflict
# Utilities
python-dotenv==1.0.0
python-dateutil==2.8.2
# Observability
prometheus-client==0.19.0
# OpenTelemetry
opentelemetry-api==1.22.0
opentelemetry-sdk==1.22.0
opentelemetry-instrumentation-fastapi==0.46b0
opentelemetry-exporter-otlp==1.22.0
opentelemetry-instrumentation-sqlalchemy==0.46b0
opentelemetry-instrumentation-httpx==0.46b0