Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion tests/test_hotkey_error_classification.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from app.blitztext_linux import _is_hotkey_device_access_error
from unittest.mock import MagicMock, call

from app.blitztext_linux import BlitztextApp, _is_hotkey_device_access_error


def test_hotkey_device_access_error_detects_missing_keyboard():
Expand All @@ -15,3 +17,28 @@ def test_hotkey_device_access_error_detects_evdev_dependency():

def test_hotkey_device_access_error_ignores_unrelated_errors():
assert not _is_hotkey_device_access_error("Audioaufnahme konnte nicht gestartet werden")


# ---------------------------------------------------------------------------
# _on_hotkey_error Slot
# ---------------------------------------------------------------------------

def test_on_hotkey_error_device_access_calls_tray_warning():
"""Device-Access-Fehler → show_tray_warning, kein show_tray_error."""
self = MagicMock()
err = "Keine Tastatur-Geraete gefunden"
BlitztextApp._on_hotkey_error(self, err)
self.show_tray_warning.assert_called_once_with(
"Hotkey Hinweis",
f"{err}\nStart/Stopp läuft über Fenster/Tray.",
)
self.show_tray_error.assert_not_called()


def test_on_hotkey_error_generic_error_calls_tray_error():
"""Nicht klassifizierter Fehler → show_tray_error, kein show_tray_warning."""
self = MagicMock()
err = "Audioaufnahme konnte nicht gestartet werden"
BlitztextApp._on_hotkey_error(self, err)
self.show_tray_error.assert_called_once_with("Hotkey Fehler", err)
self.show_tray_warning.assert_not_called()