mirror of
https://github.com/usestrix/strix.git
synced 2026-09-13 23:11:07 +00:00
Add config override regression test
This commit is contained in:
parent
6a751df13b
commit
e11958d2c9
1 changed files with 31 additions and 0 deletions
31
tests/config/test_config_override.py
Normal file
31
tests/config/test_config_override.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
from strix.config.config import Config
|
||||
|
||||
|
||||
def test_apply_config_override_clears_default_only_vars(monkeypatch, tmp_path) -> None:
|
||||
default_cfg = tmp_path / "cli-config.json"
|
||||
default_cfg.write_text(
|
||||
json.dumps({"env": {"LLM_API_BASE": "https://default.api", "STRIX_LLM": "default-model"}}),
|
||||
encoding="utf-8",
|
||||
)
|
||||
custom_cfg = tmp_path / "custom.json"
|
||||
custom_cfg.write_text(json.dumps({"env": {"STRIX_LLM": "custom-model"}}), encoding="utf-8")
|
||||
|
||||
monkeypatch.setattr(Config, "_config_file_override", None)
|
||||
monkeypatch.setattr(Config, "_applied_from_default", {})
|
||||
monkeypatch.setattr(Config, "config_dir", classmethod(lambda cls: tmp_path))
|
||||
for var_name in Config._llm_env_vars():
|
||||
monkeypatch.delenv(var_name, raising=False)
|
||||
sys.modules.pop("strix.interface.main", None)
|
||||
|
||||
from strix.interface.main import apply_config_override
|
||||
|
||||
assert os.environ.get("LLM_API_BASE") == "https://default.api"
|
||||
|
||||
apply_config_override(str(custom_cfg))
|
||||
|
||||
assert os.environ.get("STRIX_LLM") == "custom-model"
|
||||
assert "LLM_API_BASE" not in os.environ
|
||||
Loading…
Add table
Reference in a new issue