mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-05 07:25:08 +00:00
docs(rest-api): give the remote session protocol one page and move dl --remote setup to a user guide
This commit is contained in:
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import functools
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -26,6 +27,7 @@ CLIENT_METHODS = {
|
||||
"ws_connect": "GET",
|
||||
}
|
||||
SERVED = {(method, path): handler for method, path, handler, _ in routes.ROUTES}
|
||||
ROOT = Path(__file__).parents[3]
|
||||
|
||||
|
||||
@functools.cache
|
||||
@@ -103,6 +105,22 @@ def test_the_server_takes_its_remote_session_routes_from_the_protocol():
|
||||
assert {path for path in served_paths if path.startswith("/api/session")} <= protocol_paths
|
||||
|
||||
|
||||
def test_the_protocol_page_lists_each_remote_route():
|
||||
"""The route table of the protocol page holds the routes that a remote-only server mounts, and no other.
|
||||
|
||||
Each route of the table that the page itself documents has a section of its own.
|
||||
"""
|
||||
page = (ROOT / "docs" / "dev" / "rest-api" / "remote-sessions.md").read_text(encoding="utf-8")
|
||||
listed = set(re.findall(r"^\| `(GET|POST|DELETE)` \| `([^`]+)` \|", page, re.MULTILINE))
|
||||
sections = set(re.findall(r"^### `(GET|POST|DELETE) ([^`]+)`$", page, re.MULTILINE))
|
||||
assert listed == {(method, path) for method, path, _, remote in routes.ROUTES if remote}
|
||||
assert sections == listed - {
|
||||
("GET", protocol.HEALTH_ROUTE),
|
||||
("GET", protocol.SERVICES_ROUTE),
|
||||
("POST", protocol.SEARCH_ROUTE),
|
||||
}
|
||||
|
||||
|
||||
def test_the_wire_values_stay_what_older_peers_send():
|
||||
"""Both halves read one record, so only this list catches a renamed value that an older peer still sends."""
|
||||
assert {name: getattr(protocol, name) for name in ROUTE_NAMES} == {
|
||||
|
||||
Reference in New Issue
Block a user