Files
lidar_rendu/lidar_pipeline/tests/test_mapui.py
2026-09-27 17:26:41 +02:00

38 lines
1.3 KiB
Python

"""Chargeur de l'interface : fichiers web/ du paquet, versions, syntaxe JS."""
import shutil
import subprocess
import pytest
def test_constants_are_read_from_web_files():
from lidar_pipeline import mapui
for name, text in (("map.html", mapui._MAP_HTML), ("map.css", mapui._MAP_CSS),
("map.js", mapui._MAP_JS)):
assert (mapui.WEB_DIR / name).read_text(encoding="utf-8") == text
def test_web_files_ship_with_installed_package():
# Image complète : paquet installé par pip (package_data) — les trois
# fichiers doivent y être, sinon l'interface est vide en production.
import lidar_pipeline
from pathlib import Path
web = Path(lidar_pipeline.__file__).resolve().parent / "web"
for name in ("map.html", "map.css", "map.js"):
assert (web / name).is_file(), name
def test_markers_kept():
from lidar_pipeline import mapui
assert "__ASSETS_V__" in mapui._MAP_HTML
assert "__UI_VERSION__" in mapui._MAP_JS
assert "__ASSETS_V__" not in mapui.render_html()
@pytest.mark.skipif(shutil.which("node") is None, reason="node absent")
def test_js_syntax():
from lidar_pipeline import mapui
res = subprocess.run(["node", "--check", str(mapui.WEB_DIR / "map.js")],
capture_output=True, text=True)
assert res.returncode == 0, res.stderr