Projektspeicher_Abfrage beim Start behoben (3.40/3.44

This commit is contained in:
2026-04-08 13:27:00 +02:00
parent 30b17e0b83
commit f34e4ce458
3 changed files with 99 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
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()