A unified, provider-agnostic chat completions API server supporting OpenAI and AWS Bedrock
This directory contains a comprehensive test suite organized for different CI/CD scenarios. The tests are carefully separated to ensure safe CI execution while still providing real API validation.
unit
marker)integration
marker)real_api
markerreal_api
marker)# Run all safe tests (recommended for CI)
python run_tests.py --mode mock
# Run only unit tests (fastest)
python run_tests.py --mode unit
# Run integration tests with mocks
python run_tests.py --mode integration
# CI Safe modes (no API calls, no costs)
python run_tests.py --mode unit # Unit tests only
python run_tests.py --mode integration # Integration tests with mocks
python run_tests.py --mode mock # All safe tests (default)
python run_tests.py --mode all-safe # All safe tests (explicit)
# Manual/Scheduled modes (cost money)
python run_tests.py --mode real-api # Real API tests (with confirmation)
python run_tests.py --mode all # Everything (with confirmation)
# Safe for CI (no API calls)
pytest -m "not real_api" # All safe tests
pytest -m "unit" # Unit tests only
pytest -m "integration and not real_api" # Integration tests with mocks
# Costs money (manual only)
pytest -m "real_api" # Real API tests
pytest -m "openai_integration" # OpenAI specific tests
pytest -m "bedrock_integration" # Bedrock specific tests
File: .github/workflows/ci-tests.yml
# Runs on every push/PR - SAFE
- Push to main/develop
- Pull requests
- Multiple Python versions
- Coverage reporting
- No API calls, no costs
File: .github/workflows/real-api-tests.yml
# Manual trigger only - COSTS MONEY
- workflow_dispatch with confirmation
- Optional scheduled runs
- Uses secrets for API keys
- Cost acknowledgment required
tests/
โโโ test_*.py # Main test files
โโโ api/ # API-specific tests
โโโ core/ # Core functionality tests
โโโ services/ # Service layer tests
โโโ utils/ # Utility tests
โโโ conftest.py # Test configuration
โโโ README.md # This file
โโโ README_REAL_API_TESTS.md # Real API test details
File | Type | Markers | Description |
---|---|---|---|
test_models.py |
Unit | unit |
Data model validation |
test_auth.py |
Unit | unit |
Authentication logic |
test_chat.py |
Mixed | integration , some real_api |
Chat functionality |
test_bedrock_chat.py |
Mixed | integration , some real_api |
Bedrock integration |
test_real_api_integration.py |
Real API | real_api |
Comprehensive API tests |
real_api
marker only run when explicitly requestedMarker | Purpose | CI Safe | Cost | Usage |
---|---|---|---|---|
unit |
Fast unit tests | โ | ๐ | -m unit |
integration |
Integration with mocks | โ | ๐ | -m integration |
real_api |
Real API calls | โ | ๐ฐ | -m real_api |
openai_integration |
OpenAI specific | โ | ๐ฐ | -m openai_integration |
bedrock_integration |
Bedrock specific | โ | ๐ฐ | -m bedrock_integration |
slow |
Slow tests | โ | ๐ | -m "not slow" |
# Quick validation
python run_tests.py --mode unit --verbose
# Full local validation (safe)
python run_tests.py --mode mock --verbose
# Before committing
python run_tests.py --mode all-safe
# Validate real API integration (costs money)
python run_tests.py --mode real-api
# Automated (safe)
- Every commit: unit tests
- Every PR: all safe tests
- Merge to main: full safe test suite
# Manual (costs money)
- Release validation: real API tests
- Weekly scheduled: comprehensive API tests
not real_api
)real_api
marker# Check test discovery
pytest --collect-only
# Dry run without execution
pytest --collect-only -m real_api
# Run with maximum verbosity
python run_tests.py --mode unit --verbose -v
# Check marker filtering
pytest -m "not real_api" --collect-only
This organization ensures safe, fast CI execution while maintaining comprehensive validation through carefully managed real API testing.