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
This commit is contained in:
Apple
2026-03-02 08:00:35 -08:00
parent 93f94030f4
commit b9c548f1a6

View File

@@ -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"