"""Interface loader: the package's web/ files, versions, JS syntax.""" 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(): # Full image: package installed by pip (package_data) — all three files # must be there, otherwise the interface is empty in 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 not installed") 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