""" docs/MESHBAY_HTTP_API.md is generated from the routes of the hub and of the node's control API. A route added, removed or redescribed without running `python docs/generate_http_api.py` fails here. """ import importlib.util from pathlib import Path GENERATOR = Path(__file__).resolve().parents[3] / "docs" / "generate_http_api.py" def _generator(): spec = importlib.util.spec_from_file_location("generate_http_api", GENERATOR) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) return module def test_the_api_listing_matches_the_routes(): gen = _generator() assert gen.OUT.read_text(encoding="utf-8") == gen.render(), ( "docs/MESHBAY_HTTP_API.md is out of date: run python docs/generate_http_api.py") def test_every_route_says_what_it_does(): gen = _generator() bare = [f"{gen.method(r)} {r.path}" for r in gen.hub_routes() + gen.node_routes() if not gen.summary(r)] assert not bare, f"give these routes a docstring, it is their line in the listing: {bare}"