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).
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
"""Unit-Tests stabile IDs (PLAN.md §3.6, §6.3)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import uuid
|
|
|
|
from hms_domain import new_node_id, new_uuid, persistent_node_id
|
|
|
|
|
|
def test_new_uuids_are_unique_and_parseable() -> None:
|
|
a, b = new_uuid(), new_uuid()
|
|
assert a != b
|
|
uuid.UUID(a)
|
|
uuid.UUID(b)
|
|
|
|
|
|
def test_node_id_is_uuid_and_random() -> None:
|
|
a, b = new_node_id(), new_node_id()
|
|
uuid.UUID(a)
|
|
assert a != b
|
|
|
|
|
|
def test_persistent_node_id_stable_across_calls(tmp_path) -> None:
|
|
identity = tmp_path / "identity" / "node_id"
|
|
first = persistent_node_id(identity)
|
|
second = persistent_node_id(identity)
|
|
assert first == second # IP-/Hostnamenunabhängig: Datei ist Quelle der Wahrheit
|
|
assert identity.read_text(encoding="utf-8").strip() == first
|
|
|
|
|
|
def test_persistent_node_id_validated_on_load(tmp_path) -> None:
|
|
identity = tmp_path / "identity" / "node_id"
|
|
identity.parent.mkdir(parents=True)
|
|
identity.write_text("not-a-uuid", encoding="utf-8")
|
|
import pytest
|
|
|
|
with pytest.raises(ValueError):
|
|
persistent_node_id(identity)
|
|
|
|
|
|
def test_two_nodes_get_distinct_ids(tmp_path) -> None:
|
|
a = persistent_node_id(tmp_path / "a" / "node_id")
|
|
b = persistent_node_id(tmp_path / "b" / "node_id")
|
|
assert a != b # doppelte node_ids wären ein Fehler (§6.3)
|
|
|
|
|
|
def test_concurrent_creation_yields_single_id(tmp_path) -> None:
|
|
"""O_EXCL-Rennbedingung: beide Aufrufer erhalten dieselbe ID."""
|
|
identity = tmp_path / "identity" / "node_id"
|
|
id_a = persistent_node_id(identity)
|
|
# zweite Erzeugung mit bereits existierender Datei → lädt vorhandene ID
|
|
id_b = persistent_node_id(identity)
|
|
assert id_a == id_b
|