"""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
