File size: 970 Bytes
0355450 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | """Tests for configuration."""
import pytest
from src.utils import Config, LLMProvider
def test_config_default_provider():
"""Test default provider is mock."""
cfg = Config()
assert cfg.llm_provider == LLMProvider.MOCK
def test_config_model_name():
"""Test model name selection."""
cfg = Config()
cfg.llm_provider = LLMProvider.OPENAI
assert "gpt" in cfg.model_name.lower()
cfg.llm_provider = LLMProvider.LOCAL
assert "mistral" in cfg.model_name.lower()
def test_config_validate_openai_missing_key():
"""Test validation fails for OpenAI without API key."""
cfg = Config()
cfg.llm_provider = LLMProvider.OPENAI
cfg.openai_api_key = None
with pytest.raises(ValueError, match="OPENAI_API_KEY"):
cfg.validate()
def test_config_validate_success():
"""Test validation passes with correct config."""
cfg = Config()
cfg.llm_provider = LLMProvider.MOCK
cfg.validate() # Should not raise
|