mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
config: readd value has been initialized + change test removed value from settings since boolean has a native default value
This commit is contained in:
parent
f087a6b967
commit
73b795be1d
2 changed files with 13 additions and 2 deletions
|
@ -125,9 +125,9 @@ def test_app_config_get_nonexistentstuff(config_app):
|
|||
with pytest.raises(YunohostValidationError):
|
||||
app_config_get(config_app, "main.components.nonexistent")
|
||||
|
||||
app_setting(config_app, "boolean", delete=True)
|
||||
app_setting(config_app, "number", delete=True)
|
||||
with pytest.raises(YunohostError):
|
||||
app_config_get(config_app, "main.components.boolean")
|
||||
app_config_get(config_app, "main.components.number")
|
||||
|
||||
|
||||
def test_app_config_regular_setting(config_app):
|
||||
|
|
|
@ -601,6 +601,17 @@ class ConfigPanel:
|
|||
for _, section, option in config.iter_children():
|
||||
value = data = raw_settings.get(option.id, getattr(option, "default", None))
|
||||
|
||||
if isinstance(option, BaseInputOption) and option.id not in raw_settings:
|
||||
if option.default is not None:
|
||||
value = option.default
|
||||
elif option.type is OptionType.file or option.bind == "null":
|
||||
continue
|
||||
else:
|
||||
raise YunohostError(
|
||||
f"Config panel question '{option.id}' should be initialized with a value during install or upgrade.",
|
||||
raw_msg=True,
|
||||
)
|
||||
|
||||
if isinstance(data, dict):
|
||||
# Settings data if gathered from bash "ynh_app_config_show"
|
||||
# may be a custom getter that returns a dict with `value` or `current_value`
|
||||
|
|
Loading…
Add table
Reference in a new issue