30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
# retoor <retoor@molodetz.nl>
|
|
from molodetz.docs_api import all_endpoints
|
|
from molodetz.docs_api.registry import TARGET_TYPES
|
|
|
|
|
|
def test_documented_endpoints_are_unique():
|
|
keys = [(item["method"], item["path"]) for item in all_endpoints()]
|
|
assert len(keys) == len(set(keys))
|
|
|
|
|
|
def test_documented_endpoints_exist_in_app():
|
|
from molodetz.main import app
|
|
|
|
routes = {(method.upper(), path) for path, methods in app.openapi()["paths"].items() for method in methods}
|
|
missing = [(item["method"], item["path"]) for item in all_endpoints() if (item["method"], item["path"]) not in routes]
|
|
assert missing == []
|
|
|
|
|
|
def test_target_types_known():
|
|
assert set(TARGET_TYPES) == {"post", "join_request", "user"}
|
|
|
|
|
|
def test_every_product_route_is_documented():
|
|
from molodetz.main import app
|
|
|
|
documented = {(item["method"], item["path"]) for item in all_endpoints()}
|
|
routes = {(method.upper(), path) for path, methods in app.openapi()["paths"].items() for method in methods}
|
|
undocumented = sorted(route for route in routes - documented if not route[1].startswith("/docs"))
|
|
assert undocumented == []
|