tests überarbeitet
This commit is contained in:
@@ -51,6 +51,28 @@ class TestVariableWrapper(unittest.TestCase):
|
||||
"new_value",
|
||||
)
|
||||
|
||||
@patch("sn_basis.functions.variable_wrapper.QgsExpressionContextUtils.setGlobalVariable")
|
||||
def test_set_variable_global_writes_prefixed_name(self, mock_set_global):
|
||||
variable_wrapper.set_variable("verfahrensnummer", "123", scope="global")
|
||||
|
||||
mock_set_global.assert_called_once_with("sn_verfahrensnummer", "123")
|
||||
|
||||
@patch("sn_basis.functions.variable_wrapper.QgsExpressionContextUtils.globalScope")
|
||||
def test_get_variable_global_returns_empty_string_fallback(self, mock_global_scope):
|
||||
mock_global_scope.return_value = _Scope("")
|
||||
|
||||
value = variable_wrapper.get_variable("nicht_vorhanden", scope="global")
|
||||
|
||||
self.assertEqual(value, "")
|
||||
|
||||
def test_get_variable_invalid_scope_raises(self):
|
||||
with self.assertRaises(ValueError):
|
||||
variable_wrapper.get_variable("foo", scope="invalid")
|
||||
|
||||
def test_set_variable_invalid_scope_raises(self):
|
||||
with self.assertRaises(ValueError):
|
||||
variable_wrapper.set_variable("foo", "bar", scope="invalid")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user