"""Tests for strict environment configuration and endpoint normalization.""" from __future__ import annotations import pytest from swe_data_processing.config import Settings def test_endpoint_normalization() -> None: settings = Settings( api_key="test-secret", api_base="https://llm-api.cowin.run/", api_path="v1/chat/completions", ) assert settings.endpoint == "https://llm-api.cowin.run/v1/chat/completions" def test_missing_api_key_is_rejected(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.delenv("GLM_API_KEY", raising=False) with pytest.raises(ValueError, match="GLM_API_KEY"): Settings.from_env() def test_feature_only_settings_can_omit_key(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.delenv("GLM_API_KEY", raising=False) assert Settings.from_env(require_api_key=False).api_key == ""