mirror of
https://github.com/Kozea/Radicale.git
synced 2025-09-18 20:46:54 +00:00
Mark internal configuration options and sections with underscore
This commit is contained in:
parent
0bda1f4c16
commit
5371be2b39
12 changed files with 58 additions and 63 deletions
|
@ -42,11 +42,9 @@ def get_file_content(file_name):
|
|||
|
||||
|
||||
def configuration_to_dict(configuration):
|
||||
d = {}
|
||||
for section in configuration.sections():
|
||||
if configuration._schema[section].get("_internal", False):
|
||||
continue
|
||||
d[section] = {}
|
||||
for option in configuration.options(section):
|
||||
d[section][option] = configuration.get_raw(section, option)
|
||||
return d
|
||||
"""Convert configuration to a dict with raw values."""
|
||||
return {section: {option: configuration.get_raw(section, option)
|
||||
for option in configuration.options(section)
|
||||
if not option.startswith("_")}
|
||||
for section in configuration.sections()
|
||||
if not section.startswith("_")}
|
||||
|
|
|
@ -44,9 +44,9 @@ class TestBaseAuthRequests(BaseTest):
|
|||
self.configuration.update({
|
||||
"storage": {"filesystem_folder": self.colpath},
|
||||
# Disable syncing to disk for better performance
|
||||
"internal": {"filesystem_fsync": "False"},
|
||||
"_internal": {"filesystem_fsync": "False"},
|
||||
# Set incorrect authentication delay to a very low value
|
||||
"auth": {"delay": "0.002"}}, "test", internal=True)
|
||||
"auth": {"delay": "0.002"}}, "test", privileged=True)
|
||||
|
||||
def teardown(self):
|
||||
shutil.rmtree(self.colpath)
|
||||
|
|
|
@ -1350,9 +1350,9 @@ permissions: RrWw""")
|
|||
"storage": {"type": self.storage_type,
|
||||
"filesystem_folder": self.colpath},
|
||||
# Disable syncing to disk for better performance
|
||||
"internal": {"filesystem_fsync": "False"},
|
||||
"_internal": {"filesystem_fsync": "False"},
|
||||
"rights": {"file": rights_file_path,
|
||||
"type": "from_file"}}, "test", internal=True)
|
||||
"type": "from_file"}}, "test", privileged=True)
|
||||
self.application = Application(self.configuration)
|
||||
|
||||
def teardown(self):
|
||||
|
@ -1373,8 +1373,8 @@ class TestMultiFileSystem(BaseFileSystemTest, BaseRequestsMixIn):
|
|||
|
||||
def test_fsync(self):
|
||||
"""Create a directory and file with syncing enabled."""
|
||||
self.configuration.update({
|
||||
"internal": {"filesystem_fsync": "True"}}, "test", internal=True)
|
||||
self.configuration.update({"_internal": {"filesystem_fsync": "True"}},
|
||||
"test", privileged=True)
|
||||
self.application = Application(self.configuration)
|
||||
self.mkcalendar("/calendar.ics/")
|
||||
|
||||
|
|
|
@ -133,13 +133,13 @@ class TestConfig:
|
|||
|
||||
def test_internal(self):
|
||||
configuration = config.load()
|
||||
configuration.update({"internal": {"internal_server": "True"}}, "test",
|
||||
internal=True)
|
||||
configuration.update({"_internal": {"internal_server": "True"}},
|
||||
"test", privileged=True)
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
configuration.update(
|
||||
{"internal": {"internal_server": "True"}}, "test")
|
||||
{"_internal": {"internal_server": "True"}}, "test")
|
||||
e = exc_info.value
|
||||
assert "Invalid section 'internal'" in str(e)
|
||||
assert "Invalid section '_internal'" in str(e)
|
||||
|
||||
def test_plugin_schema(self):
|
||||
plugin_schema = {"auth": {"new_option": {"value": "False",
|
||||
|
|
|
@ -37,7 +37,8 @@ class TestBaseRightsRequests(BaseTest):
|
|||
self.configuration.update({
|
||||
"storage": {"filesystem_folder": self.colpath},
|
||||
# Disable syncing to disk for better performance
|
||||
"internal": {"filesystem_fsync": "False"}}, "test", internal=True)
|
||||
"_internal": {"filesystem_fsync": "False"}},
|
||||
"test", privileged=True)
|
||||
|
||||
def teardown(self):
|
||||
shutil.rmtree(self.colpath)
|
||||
|
|
|
@ -68,7 +68,8 @@ class TestBaseServerRequests(BaseTest):
|
|||
# Enable debugging for new processes
|
||||
"logging": {"level": "debug"},
|
||||
# Disable syncing to disk for better performance
|
||||
"internal": {"filesystem_fsync": "False"}}, "test", internal=True)
|
||||
"_internal": {"filesystem_fsync": "False"}},
|
||||
"test", privileged=True)
|
||||
self.thread = threading.Thread(target=server.serve, args=(
|
||||
self.configuration, shutdown_socket_out))
|
||||
ssl_context = ssl.create_default_context()
|
||||
|
@ -147,7 +148,7 @@ class TestBaseServerRequests(BaseTest):
|
|||
def test_command_line_interface(self):
|
||||
config_args = []
|
||||
for section, values in config.DEFAULT_CONFIG_SCHEMA.items():
|
||||
if values.get("_internal", False):
|
||||
if section.startswith("_"):
|
||||
continue
|
||||
for option, data in values.items():
|
||||
if option.startswith("_"):
|
||||
|
|
|
@ -35,7 +35,8 @@ class TestBaseWebRequests(BaseTest):
|
|||
self.configuration.update({
|
||||
"storage": {"filesystem_folder": self.colpath},
|
||||
# Disable syncing to disk for better performance
|
||||
"internal": {"filesystem_fsync": "False"}}, "test", internal=True)
|
||||
"_internal": {"filesystem_fsync": "False"}},
|
||||
"test", privileged=True)
|
||||
self.application = Application(self.configuration)
|
||||
|
||||
def teardown(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue