mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
monkey patch get_setting_description
This commit is contained in:
parent
1c9f6ea72e
commit
96e67ef145
2 changed files with 15 additions and 7 deletions
|
@ -265,19 +265,18 @@ def settings_reset_all():
|
|||
}
|
||||
|
||||
|
||||
def _get_setting_description(key):
|
||||
return m18n.n("global_settings_setting_%s" % key.replace(".", "_"))
|
||||
|
||||
|
||||
def _get_settings():
|
||||
def get_setting_description(key):
|
||||
if key.startswith("example"):
|
||||
# (This is for dummy stuff used during unit tests)
|
||||
return "Dummy %s setting" % key.split(".")[-1]
|
||||
return m18n.n("global_settings_setting_%s" % key.replace(".", "_"))
|
||||
|
||||
settings = {}
|
||||
|
||||
for key, value in DEFAULTS.copy().items():
|
||||
settings[key] = value
|
||||
settings[key]["value"] = value["default"]
|
||||
settings[key]["description"] = get_setting_description(key)
|
||||
settings[key]["description"] = _get_setting_description(key)
|
||||
|
||||
if not os.path.exists(SETTINGS_PATH):
|
||||
return settings
|
||||
|
@ -306,7 +305,7 @@ def _get_settings():
|
|||
for key, value in local_settings.items():
|
||||
if key in settings:
|
||||
settings[key] = value
|
||||
settings[key]["description"] = get_setting_description(key)
|
||||
settings[key]["description"] = _get_setting_description(key)
|
||||
else:
|
||||
logger.warning(
|
||||
m18n.n(
|
||||
|
|
|
@ -5,6 +5,8 @@ import pytest
|
|||
|
||||
from yunohost.utils.error import YunohostError
|
||||
|
||||
import yunohost.settings as settings
|
||||
|
||||
from yunohost.settings import (
|
||||
settings_get,
|
||||
settings_list,
|
||||
|
@ -33,6 +35,13 @@ def teardown_function(function):
|
|||
os.remove(filename)
|
||||
|
||||
|
||||
def monkey_get_setting_description(key):
|
||||
return "Dummy %s setting" % key.split(".")[-1]
|
||||
|
||||
|
||||
settings._get_setting_description = monkey_get_setting_description
|
||||
|
||||
|
||||
def test_settings_get_bool():
|
||||
assert settings_get("example.bool")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue