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_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_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_unknown_filter_key": "The filter key '{filter_key}' is incorrect.",
|
||||
"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, "main"), dict)
|
||||
assert isinstance(app_config_get(config_app, "main.components"), dict)
|
||||
# Is it expected that we return None if no value defined yet ?
|
||||
# c.f. the whole discussion about "should we have defaults" etc.
|
||||
assert app_config_get(config_app, "main.components.boolean") is None
|
||||
assert app_config_get(config_app, "main.components.boolean") == "0"
|
||||
|
||||
|
||||
def test_app_config_nopanel(legacy_app):
|
||||
|
@ -130,10 +128,14 @@ 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)
|
||||
with pytest.raises(YunohostValidationError):
|
||||
app_config_get(config_app, "main.components.boolean")
|
||||
|
||||
|
||||
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")
|
||||
|
||||
|
|
|
@ -209,6 +209,7 @@ class ConfigPanel:
|
|||
"default": {}
|
||||
}
|
||||
}
|
||||
|
||||
def convert(toml_node, node_type):
|
||||
"""Convert TOML in internal format ('full' mode used by webadmin)
|
||||
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":
|
||||
continue
|
||||
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"]]
|
||||
# In general, the value is just a simple value.
|
||||
# Sometimes it could be a dict used to overwrite the option itself
|
||||
|
@ -538,22 +539,25 @@ class StringQuestion(Question):
|
|||
argument_type = "string"
|
||||
default_value = ""
|
||||
|
||||
|
||||
class EmailQuestion(StringQuestion):
|
||||
pattern = {
|
||||
"regexp": "^.+@.+",
|
||||
"error": "config_validate_email"
|
||||
"regexp": r"^.+@.+",
|
||||
"error": "config_validate_email" # i18n: config_validate_email
|
||||
}
|
||||
|
||||
|
||||
class URLQuestion(StringQuestion):
|
||||
pattern = {
|
||||
"regexp": "^https?://.*$",
|
||||
"error": "config_validate_url"
|
||||
"regexp": r"^https?://.*$",
|
||||
"error": "config_validate_url" # i18n: config_validate_url
|
||||
}
|
||||
|
||||
|
||||
class DateQuestion(StringQuestion):
|
||||
pattern = {
|
||||
"regexp": "^\d{4}-\d\d-\d\d$",
|
||||
"error": "config_validate_date"
|
||||
"regexp": r"^\d{4}-\d\d-\d\d$",
|
||||
"error": "config_validate_date" # i18n: config_validate_date
|
||||
}
|
||||
|
||||
def _prevalidate(self):
|
||||
|
@ -566,16 +570,18 @@ class DateQuestion(StringQuestion):
|
|||
except ValueError:
|
||||
raise YunohostValidationError("config_validate_date")
|
||||
|
||||
|
||||
class TimeQuestion(StringQuestion):
|
||||
pattern = {
|
||||
"regexp": "^(1[12]|0?\d):[0-5]\d$",
|
||||
"error": "config_validate_time"
|
||||
"regexp": r"^(1[12]|0?\d):[0-5]\d$",
|
||||
"error": "config_validate_time" # i18n: config_validate_time
|
||||
}
|
||||
|
||||
|
||||
class ColorQuestion(StringQuestion):
|
||||
pattern = {
|
||||
"regexp": "^#[ABCDEFabcdef\d]{3,6}$",
|
||||
"error": "config_validate_color"
|
||||
"regexp": r"^#[ABCDEFabcdef\d]{3,6}$",
|
||||
"error": "config_validate_color" # i18n: config_validate_color
|
||||
}
|
||||
|
||||
|
||||
|
@ -799,7 +805,6 @@ class NumberQuestion(Question):
|
|||
)
|
||||
|
||||
|
||||
|
||||
class DisplayTextQuestion(Question):
|
||||
argument_type = "display_text"
|
||||
readonly = True
|
||||
|
|
Loading…
Add table
Reference in a new issue