362e089be0
Der Nutzer hat recht: Der Ordner war voller Entwicklungs-Muell. Jetzt ist sauber getrennt: ROOT (was der Nutzer sieht und braucht): - run.py = das Programm - hms_app/ = der Anwendungscode - HMS MediaEngine.app = macOS Doppelklick-Starter - HMS-Start.vbs = Windows Doppelklick-Starter - HMS-Install.vbs = Windows Erst-Installation - HMS-Mac-Install.command = macOS Homebrew-Installation - HMS-Portable-Install.command = macOS Portable-Installation (16GB-Fix) - installer_gui.py = grafischer Installer - launcher.pyw + launcher_core.py = interne Start-Logik - LIESMICH.txt = 10-Zeilen-Kurzanleitung - .gitignore _entwicklung/ (alles andere, NICHT benoetigt): - packages/ apps/ native/ plugins/ tools/ schemas/ tests/ docs/ build/ fixture_profiles/ - PLAN.md STATUS.md ERRORS.md TEST_REPORT.md CHANGELOG.md README.md - pyproject.toml uv.lock setup_*.sh/ps1 make_mac_app.py Diese Trennung gilt ab sofort fuer alle Commits. Der Nutzer kann _entwicklung/ loeschen wenn er Platz braucht - die App laeuft ohne. Verifiziert: App startet nach Aufraeumen unveraendert (Health 200).
55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
"""Unit-Tests portable Pfade (PLAN.md §9, §9.1)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from hms_launcher import AppPaths
|
|
|
|
|
|
def test_paths_are_relative_to_root(tmp_path: Path) -> None:
|
|
paths = AppPaths(root=tmp_path)
|
|
assert paths.app == tmp_path / "app"
|
|
assert paths.runtime == tmp_path / "runtime"
|
|
assert paths.gstreamer_bin == tmp_path / "runtime" / "gstreamer" / "bin"
|
|
assert paths.gstreamer_plugins == tmp_path / "runtime" / "gstreamer" / "lib" / "gstreamer-1.0"
|
|
assert paths.database == tmp_path / "userdata" / "database"
|
|
assert paths.cache == tmp_path / "userdata" / "cache"
|
|
assert paths.identity == tmp_path / "userdata" / "identity" / "node_id"
|
|
# Keine Laufwerksbuchstaben, keine absoluten Fremdpfade
|
|
assert not str(paths.app).startswith("C:")
|
|
|
|
|
|
def test_ensure_writable(tmp_path: Path) -> None:
|
|
assert AppPaths(root=tmp_path).ensure_writable() is True
|
|
assert not (tmp_path / ".write_probe").exists() # Probe wird aufgeräumt
|
|
|
|
|
|
def test_ensure_writable_false_on_write_error(tmp_path: Path, monkeypatch) -> None:
|
|
"""Schreibfehler (z. B. schreibgeschütztes Medium) → False.
|
|
|
|
Der Fehler wird simuliert, weil root in Containern Verzeichnisrechte
|
|
umgeht und ein chmod-Test dort falsch grün/rot wäre.
|
|
"""
|
|
from pathlib import Path as _Path
|
|
|
|
def _raise_write(self, *args, **kwargs):
|
|
raise OSError("read-only file system")
|
|
|
|
monkeypatch.setattr(_Path, "write_text", _raise_write)
|
|
assert AppPaths(root=tmp_path).ensure_writable() is False
|
|
|
|
|
|
def test_portable_environment_sets_gstreamer_vars(tmp_path: Path) -> None:
|
|
paths = AppPaths(root=tmp_path)
|
|
env = paths.portable_environment()
|
|
assert env["GST_PLUGIN_PATH_1_0"].endswith("gstreamer-1.0")
|
|
assert env["GST_PLUGIN_SYSTEM_PATH_1_0"] == "" # System-Plugins unterdrückt
|
|
|
|
|
|
def test_portable_environment_prepends_bundled_bin(tmp_path: Path) -> None:
|
|
gs_bin = tmp_path / "runtime" / "gstreamer" / "bin"
|
|
gs_bin.mkdir(parents=True)
|
|
env = AppPaths(root=tmp_path).portable_environment()
|
|
assert env["PATH"].startswith(str(gs_bin))
|