"""Broadcom universe registry coverage.""" from fastapi.routing import APIRoute from app.vsphere.rest.coverage import ( CORE_IMPLEMENTED, IMPLEMENTED, catalog_entries, reload_coverage, universe_stats, ) from app.vsphere.rest.stub_surface import router as stub_surface_router def test_universe_covers_broadcom_operations_index() -> None: reload_coverage() stats = universe_stats() assert stats["broadcom_operations"] == 1348 assert int(stats["unique_routes"]) >= 1000 assert int(stats["registry_methods"]) >= int(stats["unique_routes"]) assert int(stats["core_methods"]) == len(CORE_IMPLEMENTED) assert int(stats["stub_methods"]) >= 850 def test_registry_includes_put_and_all_core_routes() -> None: reload_coverage() entries = {(e["verb"], e["path"]): e["status"] for e in catalog_entries()} assert any(verb == "PUT" for verb, _path in entries) for key, status in CORE_IMPLEMENTED.items(): assert entries[key] == status def test_stub_surface_registers_each_contract_path_separately() -> None: """Universe stubs are individual FastAPI routes, not a catch-all.""" stub_routes = [ route for route in stub_surface_router.routes if isinstance(route, APIRoute) and str(route.name or "").startswith("vsphere-stub:") ] expected = {(verb, path) for (verb, path), status in IMPLEMENTED.items() if status == "stub"} registered: set[tuple[str, str]] = set() for route in stub_routes: methods = { method for method in (route.methods or set()) if method not in {"HEAD", "OPTIONS"} } assert len(methods) == 1, route.path registered.add((next(iter(methods)), route.path)) assert len(stub_routes) == len(expected) assert registered == expected assert not any("{full_path" in route.path for route in stub_routes)