42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
import importlib.util
|
|
from pathlib import Path
|
|
from unittest.mock import Mock
|
|
|
|
import pytest
|
|
|
|
|
|
def _load_progress_module():
|
|
module_path = (
|
|
Path(__file__).resolve().parents[2]
|
|
/ "src"
|
|
/ "fenrirscreenreader"
|
|
/ "commands"
|
|
/ "onScreenUpdate"
|
|
/ "65000-progress_detector.py"
|
|
)
|
|
spec = importlib.util.spec_from_file_location(
|
|
"fenrir_progress_detector", module_path
|
|
)
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_progress_detector_skips_typing_delta():
|
|
progress_module = _load_progress_module()
|
|
command = progress_module.command()
|
|
command.env = {
|
|
"commandBuffer": {"progress_monitoring": True},
|
|
"runtime": {"DebugManager": Mock(write_debug_out=Mock())},
|
|
"screen": {"new_delta": "x", "new_delta_is_typing": True},
|
|
}
|
|
command.is_current_line_prompt = Mock(return_value=False)
|
|
command.is_real_progress_update = Mock(return_value=True)
|
|
command.detect_progress = Mock()
|
|
|
|
command.run()
|
|
|
|
command.is_real_progress_update.assert_not_called()
|
|
command.detect_progress.assert_not_called()
|