From 2b9c0b4620f55b814715a33d4f1260bec7688c5c Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Fri, 19 Jun 2015 09:08:36 +0200 Subject: [PATCH] Fixed default_value in option request --- openslides/config/api.py | 1 + tests/unit/config/__init__.py | 0 tests/unit/config/test_api.py | 24 ++++++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/unit/config/__init__.py create mode 100644 tests/unit/config/test_api.py diff --git a/openslides/config/api.py b/openslides/config/api.py index 07148c78d..676158e6f 100644 --- a/openslides/config/api.py +++ b/openslides/config/api.py @@ -177,6 +177,7 @@ class ConfigVariable: """ data = { 'key': self.name, + 'default_value': self.default_value, 'value': config[self.name], 'input_type': self.input_type, 'label': self.label, diff --git a/tests/unit/config/__init__.py b/tests/unit/config/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/unit/config/test_api.py b/tests/unit/config/test_api.py new file mode 100644 index 000000000..4685ec005 --- /dev/null +++ b/tests/unit/config/test_api.py @@ -0,0 +1,24 @@ +from unittest import TestCase +from unittest.mock import patch + +from openslides.config.api import ConfigVariable + + +class TestConfigVariable(TestCase): + @patch('openslides.config.api.config', {'test_variable': None}) + def test_default_value_in_data(self): + """ + Tests, that the default_value attribute is in the 'data' property of + a ConfigVariable instance. + """ + config_variable = ConfigVariable('test_variable', 'test_default_value') + + self.assertIn( + 'default_value', + config_variable.data, + "Config_varialbe.data should have a key 'default_value'") + self.assertEqual( + config_variable.data['default_value'], + 'test_default_value', + "The value of config_variable.data['default_value'] should be the same " + "as set as second argument of ConfigVariable()")