"""Unit tests for agent_remote_diagnose helpers.""" import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT)) from server.application.agent_diagnose_service import central_status as _central_status, has_agent_monitoring as _has_agent_monitoring class _Srv: def __init__(self, key: str = "", ver: str = "") -> None: self.agent_api_key = key self.agent_version = ver def test_has_agent_monitoring(): assert _has_agent_monitoring(_Srv("nxs-x", "")) is True assert _has_agent_monitoring(_Srv("", "2.0.0")) is True assert _has_agent_monitoring(_Srv("", "")) is False def test_central_status(): hb = {"is_online": "True", "last_heartbeat": "2026-06-09T01:00:00+00:00"} assert _central_status(True, hb) == "online" hb["is_online"] = "False" assert _central_status(True, hb) == "offline" assert _central_status(True, None) == "offline" assert _central_status(False, None) == "unknown"