OpenSlides/server/tests/unit/config/test_api.py
FinnStutzenstein 2bcab5d098
Repository restructure
- moved all server related things into the folder `server`, so this
configuration is parallel to the client.
- All main "services" are now folders in the root directory
- Added Dockerfiles to each service (currently server and client)
- Added a docker compose configuration to start everything together.
Currently there are heavy dependencies into https://github.com/OpenSlides/openslides-docker-compose
- Resturctured the .gitignore. If someone needs something excluded,
please add it to the right section.
- Added initial build setup with Docker and docker-compose.
- removed setup.py. We won't deliver OpenSlides via pip anymore.
2020-08-21 08:11:13 +02:00

37 lines
1.3 KiB
Python

from typing import cast
from unittest import TestCase
from unittest.mock import patch
from openslides.core.config import ConfigVariable, ConfigVariableDict, config
from openslides.core.exceptions import ConfigNotFound
class TestConfigVariable(TestCase):
@patch("openslides.core.config.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.assertTrue(
"defaultValue" in cast(ConfigVariableDict, config_variable.data)
)
data = config_variable.data
self.assertTrue(data)
self.assertEqual(
cast(ConfigVariableDict, config_variable.data)["defaultValue"],
"test_default_value",
"The value of config_variable.data['defaultValue'] should be the same "
"as set as second argument of ConfigVariable()",
)
class TestConfigHandler(TestCase):
@patch("openslides.core.config.ConfigHandler.save_default_values")
def test_get_not_found(self, mock_save_default_values):
self.assertRaises(
ConfigNotFound, config.__getitem__, "key_leehah4Sho4ee7aCohbn"
)