From b9c548f1a63d3a7b86342924c43ed9039a1f6612 Mon Sep 17 00:00:00 2001 From: Apple Date: Mon, 2 Mar 2026 08:00:35 -0800 Subject: [PATCH] test(sofiia-console): cover noda2 router_url fallback in legacy local run Add regression coverage for router URL resolution when NODE_ID is unset and ROUTER_URL is present, and verify explicit NODES_NODA2_ROUTER_URL keeps higher priority. Made-with: Cursor --- tests/test_sofiia_config_router_fallback.py | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/test_sofiia_config_router_fallback.py diff --git a/tests/test_sofiia_config_router_fallback.py b/tests/test_sofiia_config_router_fallback.py new file mode 100644 index 00000000..4f802a1b --- /dev/null +++ b/tests/test_sofiia_config_router_fallback.py @@ -0,0 +1,35 @@ +from __future__ import annotations + +import importlib +import sys +from pathlib import Path + + +_ROOT = Path(__file__).resolve().parent.parent +_SOFIIA_PATH = _ROOT / "services" / "sofiia-console" +if str(_SOFIIA_PATH) not in sys.path: + sys.path.insert(0, str(_SOFIIA_PATH)) + + +def test_get_router_url_noda2_uses_router_url_when_node_id_unset(monkeypatch): + monkeypatch.delenv("NODE_ID", raising=False) + monkeypatch.delenv("NODES_NODA2_ROUTER_URL", raising=False) + monkeypatch.delenv("NODES_NODA1_ROUTER_URL", raising=False) + monkeypatch.setenv("ROUTER_URL", "http://example:9102") + + import app.config as config_mod # type: ignore + + importlib.reload(config_mod) + assert config_mod.get_router_url("NODA2") == "http://example:9102" + + +def test_get_router_url_noda2_prefers_explicit_node_override(monkeypatch): + monkeypatch.delenv("NODE_ID", raising=False) + monkeypatch.setenv("ROUTER_URL", "http://fallback-router:9102") + monkeypatch.setenv("NODES_NODA2_ROUTER_URL", "http://explicit-noda2:9102") + + import app.config as config_mod # type: ignore + + importlib.reload(config_mod) + assert config_mod.get_router_url("NODA2") == "http://explicit-noda2:9102" +