27 lines
986 B
Python
27 lines
986 B
Python
import os
|
|
from pathlib import Path
|
|
import pytest
|
|
from chat.config import load_settings
|
|
|
|
def test_load_settings_reads_toml(tmp_path, monkeypatch):
|
|
cfg = tmp_path / "config.toml"
|
|
cfg.write_text("""
|
|
featherless_api_key = "sk-test"
|
|
narrative_model = "dphn/Dolphin-Mistral-24B-Venice-Edition"
|
|
classifier_model = "NousResearch/Hermes-3-Llama-3.1-8B"
|
|
ooc_marker = "(("
|
|
retrieval_k = 4
|
|
""")
|
|
monkeypatch.setenv("CHAT_CONFIG_PATH", str(cfg))
|
|
s = load_settings()
|
|
assert s.featherless_api_key == "sk-test"
|
|
assert s.narrative_model.startswith("dphn/")
|
|
assert s.retrieval_k == 4
|
|
|
|
def test_chat_db_path_env_overrides_default(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("CHAT_DB_PATH", str(tmp_path / "alt.db"))
|
|
monkeypatch.setenv("CHAT_CONFIG_PATH", str(tmp_path / "config.toml"))
|
|
(tmp_path / "config.toml").write_text('featherless_api_key = "x"\n')
|
|
s = load_settings()
|
|
assert s.db_path == tmp_path / "alt.db"
|