Export names match the leftover pages. Billing HTTP wrappers stay so gateway seams are not restyled here.
40 lines
1.2 KiB
Python
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)
|