This commit is contained in:
eric
2026-05-19 06:47:07 +00:00
parent e1d7251545
commit 78e1308063
63 changed files with 2527 additions and 186 deletions

View File

@@ -5,7 +5,7 @@ import tempfile
from pathlib import Path
from unittest.mock import patch
from src.control_plane import SERVICE_SPECS, deployment_report, stack_summary
from src.control_plane import SERVICE_SPECS, deployment_report, network_iface_stats, stack_summary
class ControlPlaneServiceTests(unittest.TestCase):
@@ -23,7 +23,8 @@ class ControlPlaneServiceTests(unittest.TestCase):
)
def test_stack_summary_exposes_new_quick_links(self) -> None:
summary = stack_summary()
with patch("src.control_plane.load_stack_env", return_value={"HOSTNAME_ALIAS": "live"}):
summary = stack_summary()
links = summary["quick_links"]
for key in (
"mitmproxy",
@@ -34,13 +35,29 @@ class ControlPlaneServiceTests(unittest.TestCase):
"neko_browser",
"neko_browser_1",
"neko_browser_2",
"neko_browser_3",
):
self.assertIn(key, links)
neko_instances = summary["neko_instances"]
self.assertEqual([item["id"] for item in neko_instances], [1, 2, 3])
self.assertEqual([item["id"] for item in neko_instances], [1, 2])
self.assertEqual(links["neko_browser"], links["neko_browser_1"])
def test_stack_summary_exposes_pro_neko_links_when_configured(self) -> None:
with patch("src.control_plane.load_stack_env", return_value={"HOSTNAME_ALIAS": "live", "NEKO_INSTANCE_COUNT": "4"}):
summary = stack_summary()
links = summary["quick_links"]
self.assertIn("neko_browser_3", links)
self.assertIn("neko_browser_4", links)
self.assertEqual([item["id"] for item in summary["neko_instances"]], [1, 2, 3, 4])
def test_network_stats_expose_realtime_and_total_bandwidth_fields(self) -> None:
stats = network_iface_stats()
for key in ("interfaces", "total_rx_bytes", "total_tx_bytes", "total_rx_bps", "total_tx_bps"):
self.assertIn(key, stats)
for iface in stats["interfaces"]:
self.assertIn("rx_bps", iface)
self.assertIn("tx_bps", iface)
self.assertIn("sample_interval_seconds", iface)
def test_deployment_report_marks_live_local_ready_when_checks_pass(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
base_dir = Path(tmp)