From 325f785ef418b54b64061f79db2139cbccd8f772 Mon Sep 17 00:00:00 2001 From: ZdenekSrotyr Date: Sun, 12 Apr 2026 14:23:54 +0200 Subject: [PATCH] fix: get_instance_name reads nested instance.name from YAML --- tests/test_instance_config.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_instance_config.py b/tests/test_instance_config.py index 62f197d..9b4d1ff 100644 --- a/tests/test_instance_config.py +++ b/tests/test_instance_config.py @@ -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