SaarthiAI / tests /test_config.py
parthmax24's picture
working proto 5
8b96826
Raw
History Blame Contribute Delete
780 Bytes
"""Config key loading: placeholders from .env.example must not count as keys."""
from app import config
def test_placeholder_values_treated_as_unset(monkeypatch):
monkeypatch.setenv("GEMINI_API_KEY", "your_gemini_key_from_aistudio.google.com")
assert config.gemini_key() is None
def test_real_key_returned(monkeypatch):
monkeypatch.setenv("GEMINI_API_KEY", "AIzaRealKey123")
assert config.gemini_key() == "AIzaRealKey123"
def test_quoted_key_stripped(monkeypatch):
monkeypatch.setenv("GROQ_API_KEY", '"gsk_realkey"')
assert config.groq_key() == "gsk_realkey"
def test_missing_key_is_none(monkeypatch):
monkeypatch.delenv("GROQ_API_KEY", raising=False)
monkeypatch.delenv("groq_api_key", raising=False)
assert config.groq_key() is None