Skip to content

Commit 668ec38

Browse files
committed
test: cover hotkey error slot handling
1 parent e7becd7 commit 668ec38

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

tests/test_hotkey_error_classification.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from app.blitztext_linux import _is_hotkey_device_access_error
1+
from unittest.mock import MagicMock, call
2+
3+
from app.blitztext_linux import BlitztextApp, _is_hotkey_device_access_error
24

35

46
def test_hotkey_device_access_error_detects_missing_keyboard():
@@ -15,3 +17,28 @@ def test_hotkey_device_access_error_detects_evdev_dependency():
1517

1618
def test_hotkey_device_access_error_ignores_unrelated_errors():
1719
assert not _is_hotkey_device_access_error("Audioaufnahme konnte nicht gestartet werden")
20+
21+
22+
# ---------------------------------------------------------------------------
23+
# _on_hotkey_error Slot
24+
# ---------------------------------------------------------------------------
25+
26+
def test_on_hotkey_error_device_access_calls_tray_warning():
27+
"""Device-Access-Fehler → show_tray_warning, kein show_tray_error."""
28+
self = MagicMock()
29+
err = "Keine Tastatur-Geraete gefunden"
30+
BlitztextApp._on_hotkey_error(self, err)
31+
self.show_tray_warning.assert_called_once_with(
32+
"Hotkey Hinweis",
33+
f"{err}\nStart/Stopp läuft über Fenster/Tray.",
34+
)
35+
self.show_tray_error.assert_not_called()
36+
37+
38+
def test_on_hotkey_error_generic_error_calls_tray_error():
39+
"""Nicht klassifizierter Fehler → show_tray_error, kein show_tray_warning."""
40+
self = MagicMock()
41+
err = "Audioaufnahme konnte nicht gestartet werden"
42+
BlitztextApp._on_hotkey_error(self, err)
43+
self.show_tray_error.assert_called_once_with("Hotkey Fehler", err)
44+
self.show_tray_warning.assert_not_called()

0 commit comments

Comments
 (0)