43 lines
1000 B
Python
43 lines
1000 B
Python
import importlib.util
|
|
from pathlib import Path
|
|
from unittest.mock import Mock
|
|
|
|
import pytest
|
|
|
|
|
|
def _load_command():
|
|
module_path = (
|
|
Path(__file__).resolve().parents[2]
|
|
/ "src"
|
|
/ "fenrirscreenreader"
|
|
/ "commands"
|
|
/ "onCursorChange"
|
|
/ "85000-has_attribute.py"
|
|
)
|
|
spec = importlib.util.spec_from_file_location(
|
|
"fenrir_has_attribute", module_path
|
|
)
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
return module.command()
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_has_attribute_uses_configured_setting_name():
|
|
settings_manager = Mock()
|
|
settings_manager.get_setting_as_bool.return_value = False
|
|
command = _load_command()
|
|
command.initialize(
|
|
{
|
|
"runtime": {
|
|
"SettingsManager": settings_manager,
|
|
},
|
|
}
|
|
)
|
|
|
|
command.run()
|
|
|
|
settings_manager.get_setting_as_bool.assert_called_once_with(
|
|
"general", "has_attributes"
|
|
)
|