Files
Pulse/scripts/tests/test_reporting_schedule_docs.py
pulse-triage[bot] 7e4d373833 Align scheduled reporting and MSP plan ceiling Help docs with runtime
Document all scheduled reporting routes, status codes, schedule kinds
(resources, vm_inventory, backup_health including not_observed history
coverage and Pulse Pro runtime rendering, and patrol_digest), SMTP
pre-checks, 15 MiB attachment caps, and retry/unconfirmed semantics in
docs/API.md and docs/MSP.md, removing the stale claim that missing SMTP
falls back to saving reports to disk. Align ARCHITECTURE.md,
docs/DEPLOYMENT_MODELS.md, and docs/PULSE_PRO.md with the Scale
40-workspace MSP ceiling and no Pulse-hosted MSP service today, sync all
five shipped frontend-modern/public/docs mirrors, and add regression
tests in scripts/tests/test_reporting_schedule_docs.py and
scripts/tests/test_deployment_update_docs.py.

Contract-Neutral: Documentation and documentation regression tests only; runtime reporting routes, schedule validation, and MSP plan limits are unchanged.
Change-source: pulse-maintainer
2026-11-29 01:20:07 +00:00

123 lines
5.3 KiB
Python

#!/usr/bin/env python3
"""Keep scheduled reporting documentation aligned with backend runtime behavior."""
from pathlib import Path
import unittest
ROOT = Path(__file__).resolve().parents[2]
def read_text(rel_path: str) -> str:
return (ROOT / rel_path).read_text(encoding="utf-8")
class ReportingScheduleDocsTest(unittest.TestCase):
def test_runtime_source_anchors_still_hold(self) -> None:
routes_go = read_text("internal/api/router_routes_licensing.go")
for route in (
'"GET /api/admin/reports/schedules"',
'"POST /api/admin/reports/schedules"',
'"PUT /api/admin/reports/schedules/{id}"',
'"DELETE /api/admin/reports/schedules/{id}"',
'"POST /api/admin/reports/schedules/{id}/run"',
'"/api/admin/reports/inventory/vms/export"',
):
with self.subTest(route=route):
self.assertIn(route, routes_go)
config_go = read_text("internal/config/report_schedules.go")
for kind in (
'ReportScheduleKindResources = "resources"',
'ReportScheduleKindPatrolDigest = "patrol_digest"',
'ReportScheduleKindVMInventory = "vm_inventory"',
'ReportScheduleKindBackupHealth = "backup_health"',
"DefaultReportScheduleRetentionCount = 12",
):
with self.subTest(config_const=kind):
self.assertIn(kind, config_go)
schedules_go = read_text("internal/api/report_schedules.go")
for anchor in (
"reportScheduleAttachmentLimitBytes = 15 * 1024 * 1024",
"reportScheduleMissedRunGrace = 24 * time.Hour",
"reportScheduleMaxAttempts = 3",
'code: "email_not_ready"',
'"schedule_running"',
'"retry_unavailable"',
'r.URL.Query().Get("retry") == "true"',
):
with self.subTest(schedules_anchor=anchor):
self.assertIn(anchor, schedules_go)
backup_go = read_text("internal/api/reporting_backup_health.go")
self.assertIn("Backup health reports support VMs and containers", backup_go)
self.assertIn('summary.HistoryState = "unavailable"', backup_go)
self.assertIn('summary.HistoryState == "complete"', backup_go)
self.assertIn('case "not_observed":', backup_go)
self.assertIn("Update to a Pulse Pro runtime with backup health reporting", backup_go)
def test_msp_guide_matches_scheduled_reporting_and_smtp_validation(self) -> None:
msp = read_text("docs/MSP.md")
self.assertEqual(msp, read_text("frontend-modern/public/docs/MSP.md"))
norm = " ".join(msp.split())
# Remove the stale claim that missing SMTP falls back to saving on disk.
self.assertNotIn("saves the report to disk instead of sending it", norm)
for phrase in (
"`GET /api/admin/reports/inventory/vms/export`",
"`POST /api/admin/reports/schedules/{id}/run` (with optional `?retry=true`",
"`resources` (the default)",
"`vm_inventory`",
"Resource and tag filters are not supported.",
"`backup_health`",
"`complete`, `incomplete`, `not_observed`, or `unavailable` history coverage",
"Pulse Pro runtime with backup health reporting",
"`patrol_digest`",
"Digest schedules are weekly and email-only",
"rejected with HTTP 400 (`email_not_ready`)",
"checks SMTP before generating or saving a file",
"retry automatically up to 3 attempts (after 1 minute, then 5 minutes)",
"recorded as `unconfirmed`",
"15 MiB attachment limit",
):
with self.subTest(phrase=phrase):
self.assertIn(phrase, norm)
def test_api_guide_documents_report_schedule_routes_and_rules(self) -> None:
api = read_text("docs/API.md")
self.assertEqual(api, read_text("frontend-modern/public/docs/API.md"))
section = api.split("### Advanced Reporting (Pro)", 1)[1].split(
"### Queue and Dead-Letter Tools", 1
)[0]
norm = " ".join(section.split())
for phrase in (
"`GET /api/admin/reports/schedules` (org admin, `settings:read`, `advanced_reporting`)",
"`POST /api/admin/reports/schedules` (org admin, `settings:write`, `advanced_reporting`)",
"`PUT /api/admin/reports/schedules/{id}` (org admin, `settings:write`, `advanced_reporting`)",
"`DELETE /api/admin/reports/schedules/{id}` (org admin, `settings:write`, `advanced_reporting`)",
"`POST /api/admin/reports/schedules/{id}/run` (org admin, `settings:write`, `advanced_reporting`)",
"`?retry=true`",
"`409 schedule_running`",
"`409 retry_unavailable`",
"`202` on `retrying`",
"`502` on `unconfirmed`",
"`vm_inventory`",
"`backup_health`",
"`not_observed`",
"Pulse Pro runtime for rendering",
"`patrol_digest`",
"`400 email_not_ready`",
"`15 MiB`",
"`24h`",
"`3` attempts (`1m`, then `5m`)",
):
with self.subTest(phrase=phrase):
self.assertIn(phrase, norm)
if __name__ == "__main__":
unittest.main()