Files
periscope/tests/test_periscope_frontend_lib_rewrite.py
T
michele 2613678442 Rewrite frontend types and HTTP client in src.
Export names match the leftover pages. Billing HTTP wrappers stay so
gateway seams are not restyled here.
2026-09-20 19:41:15 +02:00

40 lines
1.2 KiB
Python

"""Native frontend types and API client live under periscope/src."""
from __future__ import annotations
import re
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SRC = ROOT / "periscope" / "src" / "frontend" / "src" / "lib"
DEP = ROOT / "periscope" / "dependency" / "frontend" / "src" / "lib"
def _exports(path: Path) -> set[str]:
text = path.read_text(encoding="utf-8")
names = set(re.findall(r"^export (?:async )?function (\w+)", text, re.M))
names |= set(re.findall(r"^export (?:interface|type|class|const) (\w+)", text, re.M))
return names
def test_frontend_lib_is_src():
for name in ("api.ts", "types.ts", "utils.ts"):
path = SRC / name
assert path.is_file(), name
head = path.read_text(encoding="utf-8")[:400]
assert "Native Periscope overlay" not in head
def test_api_keeps_page_exports():
src = _exports(SRC / "api.ts")
dep = _exports(DEP / "api.ts")
missing = dep - src
assert not missing, sorted(missing)
def test_types_keep_page_exports():
src = _exports(SRC / "types.ts")
dep = _exports(DEP / "types.ts")
missing = dep - src
assert not missing, sorted(missing)