venice_ai.presets.testing
Testing configuration preset for Venice AI SDK.
This preset is optimized for automated testing with:
- Memory backend for test isolation
- Relaxed rate limits (10x multiplier)
- Basic scheduler for predictable test execution
- Minimal overhead for fast test runs
- Circuit breaker disabled for consistent testing
create_testing_config
def create_testing_config(
test_rate_multiplier: float = 10.0,
enable_circuit_breaker: bool = False) -> VeniceAIConfig
Create a testing-optimized configuration.
This configuration is designed for automated testing and provides:
- Memory backend for test isolation (no shared state)
- Basic scheduler for deterministic execution
- 10x rate limit multiplier for faster tests
- Circuit breaker disabled by default (can be enabled for testing CB logic)
- Minimal timeouts for fast test execution
- No metrics collection overhead
Arguments:
test_rate_multiplier- Multiplier for rate limits (default: 10.0 = 10x more lenient)enable_circuit_breaker- Enable circuit breaker for testing CB logic (default: False)
Notes:
"Circuit breaker" here refers to the failure-recovery feature of the
extracted adaptive-rate-limiter package's scheduler. It only takes
effect when RateLimiterMode.ADAPTIVE (or SchedulerMode.INTELLIGENT)
is in use; under SIMPLE or DISABLED modes the configuration is inert.
Returns:
VeniceAIConfig configured for testing
Example:
>>> from venice_ai.presets import create_testing_config
>>> from venice_ai import VeniceClient
>>>
>>> # In your test fixtures
>>> @pytest.fixture
>>> async def test_client():
... config = create_testing_config()
... async with VeniceClient(config=config, api_key="test-key") as client:
... yield client
Best Practices:
- Use this preset in your pytest fixtures
- Don't use real API keys in tests
- Use VCR.py or mocks for external API calls
- Tests should be isolated and deterministic
create_testing_config_with_intelligent_scheduler
def create_testing_config_with_intelligent_scheduler(
test_rate_multiplier: float = 10.0) -> VeniceAIConfig
Create testing config with intelligent scheduler.
Use this when you want to test the intelligent scheduler behavior including rate limiting, queue management, etc.
Arguments:
test_rate_multiplier- Rate limit multiplier (default: 10.0)
Returns:
VeniceAIConfig with intelligent scheduler for testing
create_testing_config_for_circuit_breaker
def create_testing_config_for_circuit_breaker(
failure_threshold: int = 5,
reset_timeout: float = 5.0) -> VeniceAIConfig
Create testing config specifically for testing circuit breaker logic.
Arguments:
failure_threshold- Number of failures before opening circuit (default: 5)reset_timeout- Seconds before testing recovery (default: 5.0)
Notes:
"Circuit breaker" here refers to the failure-recovery feature of the
extracted adaptive-rate-limiter package's scheduler. It only takes
effect when RateLimiterMode.ADAPTIVE (or SchedulerMode.INTELLIGENT)
is in use; under SIMPLE or DISABLED modes the configuration is inert.
Returns:
VeniceAIConfig configured for circuit breaker testing