"""Simple tests for the config module."""

from pathlib import Path
from unittest.mock import MagicMock

import pytest
from acb.config import Settings


@pytest.mark.unit
class TestConfig:
    @pytest.fixture
    def temp_dir(self) -> MagicMock:
        mock_path: MagicMock = MagicMock(spec=Path)
        mock_path.__truediv__.return_value = mock_path
        return mock_path

    @pytest.fixture
    def config_files(self, temp_dir: MagicMock) -> dict[str, MagicMock]:
        app_yml = temp_dir / "app.yml"
        adapters_yml = temp_dir / "adapters.yml"
        debug_yml = temp_dir / "debug.yml"

        for file_path in (app_yml, adapters_yml, debug_yml):
            file_path.exists.return_value = True
            file_path.read_text.return_value = ""

        return {
            "app": app_yml,
            "adapters": adapters_yml,
            "debug": debug_yml,
            "dir": temp_dir,
        }

    @pytest.mark.asyncio
    async def test_settings_class(self) -> None:
        class TestSettings(Settings):
            name: str = "test_name"
            value: int = 123

        settings = TestSettings()

        assert settings.name == "test_name"
        assert settings.value == 123

        custom_settings = TestSettings(name="custom_name", value=456)

        assert custom_settings.name == "custom_name"
        assert custom_settings.value == 456

    @pytest.mark.asyncio
    async def test_app_settings(self) -> None:
        from acb.config import AppSettings

        app_settings = AppSettings()

        assert hasattr(app_settings, "name")
        assert hasattr(app_settings, "title")
        assert hasattr(app_settings, "version")

    @pytest.mark.asyncio
    async def test_debug_settings(self) -> None:
        from acb.config import DebugSettings

        debug_settings = DebugSettings()

        assert hasattr(debug_settings, "production")
        assert hasattr(debug_settings, "secrets")
        assert hasattr(debug_settings, "logger")
