from __future__ import annotations

import pytest

from codeflash_api._config import Settings


class TestSettings:
    """Tests for Settings configuration."""

    def test_defaults(self) -> None:
        """
        Default settings match development configuration.
        """
        s = Settings()

        assert "development" == s.environment
        assert 8000 == s.port
        assert 40 == s.rate_limit_max
        assert 60_000 == s.rate_limit_window_ms
        assert s.debug is False

    def test_env_override(self, monkeypatch: pytest.MonkeyPatch) -> None:
        """
        Environment variables override defaults.
        """
        monkeypatch.setenv("ENVIRONMENT", "production")
        monkeypatch.setenv("PORT", "9000")
        monkeypatch.setenv("DEBUG", "true")

        s = Settings()

        assert "production" == s.environment
        assert 9000 == s.port
        assert s.debug is True
