You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
import os
|
|
from unittest.mock import patch
|
|
|
|
from pydantic.types import SecretStr
|
|
|
|
from chat_savant.settings import SavantSettings
|
|
|
|
SETTING_DEFAULTS = {
|
|
"OPENAI_API_KEY": "EMPTY",
|
|
"OPENAI_API_BASE": "http://localhost:8000/v1",
|
|
"LLM_MODEL_NAME": "eachadea_vicuna-7b-1.1",
|
|
"ELEVEN_LABS_API_KEY": "",
|
|
"ELEVEN_LABS_MODEL": "",
|
|
}
|
|
|
|
|
|
def test_setting_defaults():
|
|
"""Regression test for settings schema."""
|
|
with patch.dict(os.environ, {}, clear=True):
|
|
savant_settings = SavantSettings()
|
|
assert len(savant_settings.dict()) == len(SETTING_DEFAULTS)
|
|
for k, v in SETTING_DEFAULTS.items():
|
|
_setting_value = getattr(savant_settings, k.lower())
|
|
unmasked_setting = (
|
|
_setting_value.get_secret_value() if isinstance(_setting_value, SecretStr) else _setting_value
|
|
)
|
|
unmasked_setting == v
|
|
|
|
|
|
def test_with_envvar_prefix():
|
|
with patch.dict(os.environ, {"SAVANT_ELEVEN_LABS_API_KEY": "thisisnotreal"}, clear=True):
|
|
savant_settings = SavantSettings()
|
|
assert savant_settings.eleven_labs_api_key.get_secret_value() == "thisisnotreal"
|