fix: get_instance_name reads nested instance.name from YAML
This commit is contained in:
parent
209643becb
commit
325f785ef4
1 changed files with 24 additions and 0 deletions
|
|
@ -10,3 +10,27 @@ class TestInstanceConfig:
|
|||
from app.instance_config import get_instance_name
|
||||
name = get_instance_name()
|
||||
assert isinstance(name, str)
|
||||
|
||||
def test_reads_nested_instance_name(self, tmp_path, monkeypatch):
|
||||
"""get_instance_name should read instance.name from YAML, not flat instance_name."""
|
||||
monkeypatch.setenv("DATA_DIR", str(tmp_path))
|
||||
monkeypatch.setenv("TESTING", "1")
|
||||
monkeypatch.setenv("JWT_SECRET_KEY", "test-secret-key-min-32-characters!!")
|
||||
|
||||
state_dir = tmp_path / "state"
|
||||
state_dir.mkdir(exist_ok=True)
|
||||
(state_dir / "instance.yaml").write_text(
|
||||
"instance:\n name: Acme Analytics\n subtitle: Data Team\n"
|
||||
)
|
||||
|
||||
import importlib
|
||||
import app.instance_config as mod
|
||||
# Reset cached config to force reload
|
||||
mod._instance_config = None
|
||||
importlib.reload(mod)
|
||||
|
||||
assert mod.get_instance_name() == "Acme Analytics"
|
||||
assert mod.get_instance_subtitle() == "Data Team"
|
||||
|
||||
# Cleanup: reset cache after test
|
||||
mod._instance_config = None
|
||||
|
|
|
|||
Loading…
Reference in a new issue