From b470c9192c00a6f03456110594c621fc41ea7bb5 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Wed, 11 Sep 2019 01:47:16 +0100 Subject: [PATCH] Add "on" to valid boolean and refactor is_true --- src/yunohost/app.py | 4 ++-- src/yunohost/tests/test_settings.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index d17ea8424..8c7b441b4 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -2903,9 +2903,9 @@ def is_true(arg): if isinstance(arg, bool): return arg elif isinstance(arg, basestring): - true_list = ['yes', 'Yes', 'true', 'True'] + true_list = ['yes', 'true', 'on'] for string in true_list: - if arg == string: + if arg.lower() == string: return True return False else: diff --git a/src/yunohost/tests/test_settings.py b/src/yunohost/tests/test_settings.py index 0da12597f..ea6c6922c 100644 --- a/src/yunohost/tests/test_settings.py +++ b/src/yunohost/tests/test_settings.py @@ -62,6 +62,8 @@ def test_settings_set(): settings_set("example.bool", False) assert settings_get("example.bool") == False + settings_set("example.bool", "on") + assert settings_get("example.bool") == True def test_settings_set_int(): settings_set("example.int", 21)