feat: enhance service status reporting with JSON output and add related tests

This commit is contained in:
2026-05-20 15:29:21 -06:00
parent b21889c4ab
commit 8c58210c0c
4 changed files with 35 additions and 4 deletions

View File

@@ -133,6 +133,22 @@ class ServiceManagerTests(unittest.TestCase):
self.assertEqual(report["services"][0]["name"], "alpha")
self.assertIn("health", report["services"][0])
def test_status_report_is_lightweight_machine_readable(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
refs = services.service_items(sample_manifest(), include_disabled=True)
with patch.object(services, "ROOT", root), \
patch.object(services, "RUNTIME_DIR", root / ".aiw" / "runtime"), \
patch.object(services, "PID_DIR", root / ".aiw" / "runtime" / "pids"), \
patch.object(services, "LOG_DIR", root / ".aiw" / "runtime" / "logs"), \
patch.object(services, "STATE_DIR", root / ".aiw" / "runtime" / "state"):
report = services.status_report("test", refs)
self.assertEqual(report["profile"], "test")
self.assertEqual(len(report["services"]), 3)
self.assertIn("status", report["services"][0])
self.assertNotIn("checks", report["services"][0])
def test_read_pid_ignores_invalid_pid_file(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
pid_dir = Path(tmp) / "pids"