forked from HAL9000/cleveragents-core
2917aa7ddb
Extend _check_providers() in system.py to report diagnostic status for all 9 providers supported by ProviderRegistry: OpenAI, Anthropic, Google, Azure, OpenRouter, Gemini, Cohere, Groq, and Together AI. Previously only 4 providers (OpenAI, Anthropic, Google, OpenRouter) were checked, leaving users of Groq, Together AI, Cohere, Azure, and Gemini with no diagnostic feedback about their provider configuration. Changes: - Add Azure (AZURE_OPENAI_API_KEY), Gemini (GEMINI_API_KEY), Cohere (COHERE_API_KEY), Groq (GROQ_API_KEY), and Together AI (TOGETHER_API_KEY) to the provider_checks list - Add Behave feature file with 11 scenarios covering all 9 providers (presence, OK status when configured, WARN with recommendation when not) ISSUES CLOSED: #3422
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
"""Mock Settings object for testing diagnostics and provider configuration.
|
|
|
|
This mock is used in Behave step definitions to simulate the Settings object
|
|
returned by ``cleveragents.config.settings.get_settings()``.
|
|
|
|
Following the mock placement rule (ADR-022), all mocking code must exist only
|
|
within the ``features/mocks/`` directory and never in step definition files.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
|
def make_settings_mock(configured_providers: set[str] | None = None) -> MagicMock:
|
|
"""Build a mock Settings object for use in Behave step definitions.
|
|
|
|
Args:
|
|
configured_providers: Set of provider names that should appear configured.
|
|
If None, no providers are configured.
|
|
|
|
Returns:
|
|
A MagicMock that mimics the Settings interface, with
|
|
``has_provider_configured()`` returning True only for providers in
|
|
``configured_providers``.
|
|
"""
|
|
if configured_providers is None:
|
|
configured_providers = set()
|
|
|
|
s = MagicMock()
|
|
|
|
def has_provider_configured(provider: str | None = None) -> bool:
|
|
if provider is None:
|
|
return bool(configured_providers)
|
|
return provider in configured_providers
|
|
|
|
s.has_provider_configured = MagicMock(side_effect=has_provider_configured)
|
|
return s
|