Merge pull request #1556 from ostcar/config_default_value

Fixed missing config default_value for OPTIONS requests.
This commit is contained in:
Norman Jäckel 2015-06-21 21:50:38 +02:00
commit 4c9683a1b3
3 changed files with 25 additions and 0 deletions

View File

@ -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,

View File

View File

@ -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()")