"""Guard: the checked-in clients/openapi.json must cover the live app (#32).

If someone adds/removes a route without refreshing the snapshot, this fails —
so hexa's spec + generated clients never silently drift from the real API.
Refresh with the one-liner in clients/README.md.
"""
import json
from pathlib import Path

import app

HERE = Path(__file__).resolve().parent.parent


def test_snapshot_paths_match_live_app():
    snap = json.loads((HERE / "clients" / "openapi.json").read_text())
    live = app.app.openapi()
    assert set(snap["paths"]) == set(live["paths"]), (
        "clients/openapi.json is stale — re-dump it (see clients/README.md)"
    )


def test_snapshot_advertises_public_server():
    snap = json.loads((HERE / "clients" / "openapi.json").read_text())
    assert snap["servers"][0]["url"] == "https://api.nech.pl/audio/v1"
