File size: 835 Bytes
d44b33d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | """Settings behaviour for Hugging Face Spaces and Hub tokens."""
from api.config import Settings
def test_space_id_without_llm_provider_env_uses_huggingface_and_hf_token(monkeypatch):
monkeypatch.setenv("SPACE_ID", "author/repo")
monkeypatch.delenv("LLM_PROVIDER", raising=False)
monkeypatch.delenv("HUGGINGFACE_API_KEY", raising=False)
monkeypatch.setenv("HF_TOKEN", "hf_test_token")
s = Settings(_env_file=None)
assert s.llm_provider == "huggingface"
assert s.huggingface_api_key == "hf_test_token"
def test_space_id_respects_explicit_llm_provider_ollama(monkeypatch):
monkeypatch.setenv("SPACE_ID", "author/repo")
monkeypatch.setenv("LLM_PROVIDER", "ollama")
monkeypatch.delenv("HUGGINGFACE_API_KEY", raising=False)
s = Settings(_env_file=None)
assert s.llm_provider == "ollama"
|