40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import unittest
|
|
from unittest.mock import patch
|
|
|
|
from sn_basis.functions import verfahrensgebiet_manager
|
|
|
|
|
|
class _Scope:
|
|
def __init__(self, value: str):
|
|
self._value = value
|
|
|
|
def variable(self, _name: str) -> str:
|
|
return self._value
|
|
|
|
|
|
class TestVerfahrensgebietManager(unittest.TestCase):
|
|
|
|
@patch("sn_basis.functions.verfahrensgebiet_manager._find_verfahrensgebiet_layer")
|
|
@patch("sn_basis.functions.variable_wrapper.QgsProject.instance")
|
|
@patch("sn_basis.functions.variable_wrapper.QgsExpressionContextUtils.setProjectVariable")
|
|
@patch("sn_basis.functions.variable_wrapper.QgsExpressionContextUtils.projectScope")
|
|
def test_update_without_layer_does_not_write_when_already_empty(
|
|
self,
|
|
mock_project_scope,
|
|
mock_set_project_variable,
|
|
mock_project_instance,
|
|
mock_find_layer,
|
|
):
|
|
mock_find_layer.return_value = (None, None)
|
|
mock_project_instance.return_value = object()
|
|
mock_project_scope.return_value = _Scope("")
|
|
|
|
result = verfahrensgebiet_manager._update_verfahrensgebiet_from_project()
|
|
|
|
self.assertFalse(result)
|
|
mock_set_project_variable.assert_not_called()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|