49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
from unittest.mock import Mock
|
|
|
|
import pytest
|
|
|
|
from fenrirscreenreader.core.outputManager import OutputManager
|
|
|
|
|
|
def build_output_manager():
|
|
settings_manager = Mock()
|
|
settings_manager.get_setting_as_bool.return_value = True
|
|
settings_manager.get_setting_as_float.return_value = 1.0
|
|
sound_driver = Mock()
|
|
output_manager = OutputManager()
|
|
output_manager.env = {
|
|
"soundIcons": {
|
|
"ACCEPT": "/tmp/Accept.wav",
|
|
"ERRORSCREEN": "/tmp/ErrorScreen.wav",
|
|
},
|
|
"runtime": {
|
|
"SettingsManager": settings_manager,
|
|
"SoundDriver": sound_driver,
|
|
"SpeechDriver": Mock(),
|
|
"DebugManager": Mock(write_debug_out=Mock()),
|
|
},
|
|
}
|
|
return output_manager, sound_driver
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_present_text_allows_sound_only_feedback():
|
|
output_manager, sound_driver = build_output_manager()
|
|
|
|
output_manager.present_text("", sound_icon="Accept", interrupt=False)
|
|
|
|
sound_driver.play_sound_file.assert_called_once_with(
|
|
"/tmp/Accept.wav", False
|
|
)
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_play_sound_supports_error_alias():
|
|
output_manager, sound_driver = build_output_manager()
|
|
|
|
assert output_manager.play_sound("Error") is True
|
|
|
|
sound_driver.play_sound_file.assert_called_once_with(
|
|
"/tmp/ErrorScreen.wav", True
|
|
)
|