Audit frontend static API endpoints
这个提交存在于:
父节点
fb20d820fc
当前提交
0e1ed7d8ef
共有 1 个文件被更改,包括 28 次插入 和 0 次删除
|
|
@ -0,0 +1,28 @@
|
||||||
|
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()
|
||||||
正在加载…
添加表格
在新工单中引用