29 行
899 B
Python
29 行
899 B
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import re
|
||
|
|
import unittest
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
from backend.route_registry import route_manifest
|
||
|
|
from database.db_helper import REPO_ROOT
|
||
|
|
|
||
|
|
|
||
|
|
class FrontendApiContractTests(unittest.TestCase):
|
||
|
|
def test_static_frontend_endpoints_exist_in_backend_registry(self):
|
||
|
|
endpoint_source = (REPO_ROOT / "frontend" / "shared" / "api" / "endpoints.ts").read_text(
|
||
|
|
encoding="utf-8"
|
||
|
|
)
|
||
|
|
frontend_static = {
|
||
|
|
match.group("endpoint")
|
||
|
|
for match in re.finditer(r"\w+:\s*\"(?P<endpoint>[^\"]+)\"", endpoint_source)
|
||
|
|
if "${" not in match.group("endpoint")
|
||
|
|
}
|
||
|
|
backend_endpoints = {route["endpoint"] for route in route_manifest()}
|
||
|
|
|
||
|
|
self.assertTrue(frontend_static)
|
||
|
|
self.assertEqual(sorted(frontend_static - backend_endpoints), [])
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
unittest.main()
|