mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Misc fixes, try to fix tests
This commit is contained in:
parent
ce34bb75c4
commit
02814833d5
3 changed files with 23 additions and 17 deletions
|
@ -143,7 +143,6 @@
|
||||||
"config_apply_failed": "Applying the new configuration failed: {error}",
|
"config_apply_failed": "Applying the new configuration failed: {error}",
|
||||||
"config_cant_set_value_on_section": "You can't set a single value on an entire config section.",
|
"config_cant_set_value_on_section": "You can't set a single value on an entire config section.",
|
||||||
"config_forbidden_keyword": "The keyword '{keyword}' is reserved, you can't create or use a config panel with a question with this id.",
|
"config_forbidden_keyword": "The keyword '{keyword}' is reserved, you can't create or use a config panel with a question with this id.",
|
||||||
"config_missing_init_value": "Config panel question '{question}' should be initialize with a value during install or upgrade.",
|
|
||||||
"config_no_panel": "No config panel found.",
|
"config_no_panel": "No config panel found.",
|
||||||
"config_unknown_filter_key": "The filter key '{filter_key}' is incorrect.",
|
"config_unknown_filter_key": "The filter key '{filter_key}' is incorrect.",
|
||||||
"config_validate_color": "Should be a valid RGB hexadecimal color",
|
"config_validate_color": "Should be a valid RGB hexadecimal color",
|
||||||
|
|
|
@ -105,9 +105,7 @@ def test_app_config_get(config_app):
|
||||||
assert isinstance(app_config_get(config_app, export=True), dict)
|
assert isinstance(app_config_get(config_app, export=True), dict)
|
||||||
assert isinstance(app_config_get(config_app, "main"), dict)
|
assert isinstance(app_config_get(config_app, "main"), dict)
|
||||||
assert isinstance(app_config_get(config_app, "main.components"), dict)
|
assert isinstance(app_config_get(config_app, "main.components"), dict)
|
||||||
# Is it expected that we return None if no value defined yet ?
|
assert app_config_get(config_app, "main.components.boolean") == "0"
|
||||||
# c.f. the whole discussion about "should we have defaults" etc.
|
|
||||||
assert app_config_get(config_app, "main.components.boolean") is None
|
|
||||||
|
|
||||||
|
|
||||||
def test_app_config_nopanel(legacy_app):
|
def test_app_config_nopanel(legacy_app):
|
||||||
|
@ -130,10 +128,14 @@ def test_app_config_get_nonexistentstuff(config_app):
|
||||||
with pytest.raises(YunohostValidationError):
|
with pytest.raises(YunohostValidationError):
|
||||||
app_config_get(config_app, "main.components.nonexistent")
|
app_config_get(config_app, "main.components.nonexistent")
|
||||||
|
|
||||||
|
app_setting(config_app, "boolean", delete=True)
|
||||||
|
with pytest.raises(YunohostValidationError):
|
||||||
|
app_config_get(config_app, "main.components.boolean")
|
||||||
|
|
||||||
|
|
||||||
def test_app_config_regular_setting(config_app):
|
def test_app_config_regular_setting(config_app):
|
||||||
|
|
||||||
assert app_config_get(config_app, "main.components.boolean") is None
|
assert app_config_get(config_app, "main.components.boolean") == "0"
|
||||||
|
|
||||||
app_config_set(config_app, "main.components.boolean", "no")
|
app_config_set(config_app, "main.components.boolean", "no")
|
||||||
|
|
||||||
|
|
|
@ -209,6 +209,7 @@ class ConfigPanel:
|
||||||
"default": {}
|
"default": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def convert(toml_node, node_type):
|
def convert(toml_node, node_type):
|
||||||
"""Convert TOML in internal format ('full' mode used by webadmin)
|
"""Convert TOML in internal format ('full' mode used by webadmin)
|
||||||
Here are some properties of 1.0 config panel in toml:
|
Here are some properties of 1.0 config panel in toml:
|
||||||
|
@ -284,7 +285,7 @@ class ConfigPanel:
|
||||||
if option["type"] in allowed_empty_type or option["bind"] == "null":
|
if option["type"] in allowed_empty_type or option["bind"] == "null":
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
raise YunohostError("config_missing_init_value", question=option["id"])
|
raise YunohostError(f"Config panel question '{option['id']}' should be initialized with a value during install or upgrade.")
|
||||||
value = self.values[option["name"]]
|
value = self.values[option["name"]]
|
||||||
# In general, the value is just a simple value.
|
# In general, the value is just a simple value.
|
||||||
# Sometimes it could be a dict used to overwrite the option itself
|
# Sometimes it could be a dict used to overwrite the option itself
|
||||||
|
@ -538,22 +539,25 @@ class StringQuestion(Question):
|
||||||
argument_type = "string"
|
argument_type = "string"
|
||||||
default_value = ""
|
default_value = ""
|
||||||
|
|
||||||
|
|
||||||
class EmailQuestion(StringQuestion):
|
class EmailQuestion(StringQuestion):
|
||||||
pattern = {
|
pattern = {
|
||||||
"regexp": "^.+@.+",
|
"regexp": r"^.+@.+",
|
||||||
"error": "config_validate_email"
|
"error": "config_validate_email" # i18n: config_validate_email
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class URLQuestion(StringQuestion):
|
class URLQuestion(StringQuestion):
|
||||||
pattern = {
|
pattern = {
|
||||||
"regexp": "^https?://.*$",
|
"regexp": r"^https?://.*$",
|
||||||
"error": "config_validate_url"
|
"error": "config_validate_url" # i18n: config_validate_url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class DateQuestion(StringQuestion):
|
class DateQuestion(StringQuestion):
|
||||||
pattern = {
|
pattern = {
|
||||||
"regexp": "^\d{4}-\d\d-\d\d$",
|
"regexp": r"^\d{4}-\d\d-\d\d$",
|
||||||
"error": "config_validate_date"
|
"error": "config_validate_date" # i18n: config_validate_date
|
||||||
}
|
}
|
||||||
|
|
||||||
def _prevalidate(self):
|
def _prevalidate(self):
|
||||||
|
@ -566,16 +570,18 @@ class DateQuestion(StringQuestion):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise YunohostValidationError("config_validate_date")
|
raise YunohostValidationError("config_validate_date")
|
||||||
|
|
||||||
|
|
||||||
class TimeQuestion(StringQuestion):
|
class TimeQuestion(StringQuestion):
|
||||||
pattern = {
|
pattern = {
|
||||||
"regexp": "^(1[12]|0?\d):[0-5]\d$",
|
"regexp": r"^(1[12]|0?\d):[0-5]\d$",
|
||||||
"error": "config_validate_time"
|
"error": "config_validate_time" # i18n: config_validate_time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ColorQuestion(StringQuestion):
|
class ColorQuestion(StringQuestion):
|
||||||
pattern = {
|
pattern = {
|
||||||
"regexp": "^#[ABCDEFabcdef\d]{3,6}$",
|
"regexp": r"^#[ABCDEFabcdef\d]{3,6}$",
|
||||||
"error": "config_validate_color"
|
"error": "config_validate_color" # i18n: config_validate_color
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -799,7 +805,6 @@ class NumberQuestion(Question):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DisplayTextQuestion(Question):
|
class DisplayTextQuestion(Question):
|
||||||
argument_type = "display_text"
|
argument_type = "display_text"
|
||||||
readonly = True
|
readonly = True
|
||||||
|
|
Loading…
Add table
Reference in a new issue