From: Michael Wagner Date: Mon, 3 Feb 2025 16:10:18 +0000 (+0100) Subject: pydev-s6git X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/SVBaL.git/commitdiff_plain/336e7e9c72512cfdaabfe8a485b11e8342042d8f pydev-s6git --- diff --git a/python/eh_util/eh_app/AWK/config.py b/python/eh_util/eh_app/AWK/config.py index ee76c7b..4485597 100644 --- a/python/eh_util/eh_app/AWK/config.py +++ b/python/eh_util/eh_app/AWK/config.py @@ -31,10 +31,12 @@ class Config: # check, if entry already exists data = ConfigData.objects.filter(verein=self.verein, key=key) if data: - # check value - if data.value != value: - data.value = value - data.save() + # check data set + if len(data) != 1: + raise RuntimeError("config entry not unique") + if data[0].value != value: + data[0].value = value + data[0].save() else: data = ConfigData(verein=self.verein, key=key, value=value) data.save() diff --git a/python/eh_util/eh_app/tests.py b/python/eh_util/eh_app/tests.py index ef849cd..365207f 100644 --- a/python/eh_util/eh_app/tests.py +++ b/python/eh_util/eh_app/tests.py @@ -10,6 +10,12 @@ class TestConfig(TestCase): val = cf.getConfig("bla") assert (val == "blub") + + # change setting + cf.setConfig("bla", "bar") + val = cf.getConfig("bla") + assert (val == "bar") + class TestQModel(TestCase): def setUp(self):