refactor: Windows-Hotkey-Record in eigenes Modul auslagern
This commit is contained in:
+7
-7
@@ -111,7 +111,7 @@ class TestApplySystemTheme:
|
||||
class TestCheckHotkeyConflict:
|
||||
def test_returns_false_when_key_is_free(self):
|
||||
from unittest.mock import patch, MagicMock
|
||||
from whisper_local.tray._settings import check_hotkey_conflict
|
||||
from whisper_local.tray._hotkey_record_pynput import check_hotkey_conflict
|
||||
|
||||
mock_user32 = MagicMock()
|
||||
mock_user32.RegisterHotKey.return_value = 1 # Erfolg
|
||||
@@ -123,7 +123,7 @@ class TestCheckHotkeyConflict:
|
||||
|
||||
def test_returns_true_when_key_is_taken(self):
|
||||
from unittest.mock import patch, MagicMock
|
||||
from whisper_local.tray._settings import check_hotkey_conflict
|
||||
from whisper_local.tray._hotkey_record_pynput import check_hotkey_conflict
|
||||
|
||||
mock_user32 = MagicMock()
|
||||
mock_user32.RegisterHotKey.return_value = 0 # Belegt
|
||||
@@ -134,7 +134,7 @@ class TestCheckHotkeyConflict:
|
||||
mock_user32.UnregisterHotKey.assert_not_called()
|
||||
|
||||
def test_returns_false_for_unknown_key(self):
|
||||
from whisper_local.tray._settings import check_hotkey_conflict
|
||||
from whisper_local.tray._hotkey_record_pynput import check_hotkey_conflict
|
||||
result = check_hotkey_conflict("KEY_NONEXISTENT_999")
|
||||
assert result is False
|
||||
|
||||
@@ -165,22 +165,22 @@ class TestListMicrophones:
|
||||
class TestPynputToEvdevKey:
|
||||
def test_function_key(self):
|
||||
from pynput.keyboard import Key
|
||||
from whisper_local.tray._settings import pynput_to_evdev_key
|
||||
from whisper_local.tray._hotkey_record_pynput import pynput_to_evdev_key
|
||||
assert pynput_to_evdev_key(Key.f12) == "KEY_F12"
|
||||
|
||||
def test_space_key(self):
|
||||
from pynput.keyboard import Key
|
||||
from whisper_local.tray._settings import pynput_to_evdev_key
|
||||
from whisper_local.tray._hotkey_record_pynput import pynput_to_evdev_key
|
||||
assert pynput_to_evdev_key(Key.space) == "KEY_SPACE"
|
||||
|
||||
def test_char_key(self):
|
||||
from pynput.keyboard import KeyCode
|
||||
from whisper_local.tray._settings import pynput_to_evdev_key
|
||||
from whisper_local.tray._hotkey_record_pynput import pynput_to_evdev_key
|
||||
key = KeyCode.from_char("a")
|
||||
assert pynput_to_evdev_key(key) == "KEY_A"
|
||||
|
||||
def test_unknown_returns_empty(self):
|
||||
from whisper_local.tray._settings import pynput_to_evdev_key
|
||||
from whisper_local.tray._hotkey_record_pynput import pynput_to_evdev_key
|
||||
assert pynput_to_evdev_key(None) == ""
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user