Files
cleveragents-core/features/mocks/settings_mock.py
T
freemo 2917aa7ddb
CI / lint (pull_request) Successful in 24s
CI / typecheck (pull_request) Successful in 51s
CI / quality (pull_request) Successful in 46s
CI / security (pull_request) Successful in 1m0s
CI / build (pull_request) Successful in 38s
CI / helm (pull_request) Successful in 24s
CI / unit_tests (pull_request) Successful in 6m47s
CI / e2e_tests (pull_request) Successful in 18m26s
CI / docker (pull_request) Successful in 1m29s
CI / integration_tests (pull_request) Successful in 22m58s
CI / coverage (pull_request) Successful in 10m55s
CI / status-check (pull_request) Successful in 2s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 56m49s
fix(cli): extend agents diagnostics to check all 9 supported providers
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
2026-04-05 21:06:04 +00:00

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