Tests updated. Attempt to fix remaining problems with forward keypress and numlock reporting.

This commit is contained in:
Storm Dragon
2026-05-12 02:32:26 -04:00
parent 38ef1c2d72
commit 878eef5c5b
5 changed files with 171 additions and 10 deletions
+65
View File
@@ -0,0 +1,65 @@
import importlib.util
from pathlib import Path
from unittest.mock import Mock
import pytest
def load_numlock_command():
command_path = (
Path(__file__).parents[2]
/ "src"
/ "fenrirscreenreader"
/ "commands"
/ "onKeyInput"
/ "80500-numlock.py"
)
spec = importlib.util.spec_from_file_location(
"numlock_command", command_path
)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module.command
@pytest.mark.unit
def test_numlock_off_can_be_announced_from_release_event():
output_manager = Mock()
command = load_numlock_command()()
command.initialize(
{
"input": {
"old_num_lock": True,
"new_num_lock": False,
"curr_input": [],
"prev_input": ["KEY_NUMLOCK"],
},
"runtime": {"OutputManager": output_manager},
}
)
command.run()
output_manager.present_text.assert_called_once()
assert output_manager.present_text.call_args.args[0] == "Numlock off"
@pytest.mark.unit
def test_numlock_command_ignores_non_numlock_release():
output_manager = Mock()
command = load_numlock_command()()
command.initialize(
{
"input": {
"old_num_lock": True,
"new_num_lock": False,
"curr_input": [],
"prev_input": ["KEY_KP1"],
},
"runtime": {"OutputManager": output_manager},
}
)
command.run()
output_manager.present_text.assert_not_called()