mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[CI] Format code
This commit is contained in:
parent
be5869cd3b
commit
712e2bb1c9
5 changed files with 43 additions and 16 deletions
|
@ -12,6 +12,7 @@ from yunohost.utils.error import YunohostError
|
|||
|
||||
logger = logging.getLogger("yunohost.authenticators.ldap_admin")
|
||||
|
||||
|
||||
class Authenticator(BaseAuthenticator):
|
||||
|
||||
name = "ldap_admin"
|
||||
|
@ -57,7 +58,10 @@ class Authenticator(BaseAuthenticator):
|
|||
raise
|
||||
else:
|
||||
if who != self.admindn:
|
||||
raise YunohostError(f"Not logged with the appropriate identity ? Found {who}, expected {self.admindn} !?", raw_msg=True)
|
||||
raise YunohostError(
|
||||
f"Not logged with the appropriate identity ? Found {who}, expected {self.admindn} !?",
|
||||
raw_msg=True,
|
||||
)
|
||||
finally:
|
||||
# Free the connection, we don't really need it to keep it open as the point is only to check authentication...
|
||||
if con:
|
||||
|
|
|
@ -81,7 +81,8 @@ def pytest_cmdline_main(config):
|
|||
import yunohost
|
||||
|
||||
yunohost.init(debug=config.option.yunodebug)
|
||||
class DummyInterface():
|
||||
|
||||
class DummyInterface:
|
||||
|
||||
type = "test"
|
||||
|
||||
|
|
|
@ -180,7 +180,9 @@ def test_parse_args_in_yunohost_format_string_input_test_ask():
|
|||
]
|
||||
answers = {}
|
||||
|
||||
with patch.object(Moulinette.interface, "prompt", return_value="some_value") as prompt:
|
||||
with patch.object(
|
||||
Moulinette.interface, "prompt", return_value="some_value"
|
||||
) as prompt:
|
||||
_parse_args_in_yunohost_format(answers, questions)
|
||||
prompt.assert_called_with(ask_text, False)
|
||||
|
||||
|
@ -197,7 +199,9 @@ def test_parse_args_in_yunohost_format_string_input_test_ask_with_default():
|
|||
]
|
||||
answers = {}
|
||||
|
||||
with patch.object(Moulinette.interface, "prompt", return_value="some_value") as prompt:
|
||||
with patch.object(
|
||||
Moulinette.interface, "prompt", return_value="some_value"
|
||||
) as prompt:
|
||||
_parse_args_in_yunohost_format(answers, questions)
|
||||
prompt.assert_called_with("%s (default: %s)" % (ask_text, default_text), False)
|
||||
|
||||
|
@ -215,7 +219,9 @@ def test_parse_args_in_yunohost_format_string_input_test_ask_with_example():
|
|||
]
|
||||
answers = {}
|
||||
|
||||
with patch.object(Moulinette.interface, "prompt", return_value="some_value") as prompt:
|
||||
with patch.object(
|
||||
Moulinette.interface, "prompt", return_value="some_value"
|
||||
) as prompt:
|
||||
_parse_args_in_yunohost_format(answers, questions)
|
||||
assert ask_text in prompt.call_args[0][0]
|
||||
assert example_text in prompt.call_args[0][0]
|
||||
|
@ -234,7 +240,9 @@ def test_parse_args_in_yunohost_format_string_input_test_ask_with_help():
|
|||
]
|
||||
answers = {}
|
||||
|
||||
with patch.object(Moulinette.interface, "prompt", return_value="some_value") as prompt:
|
||||
with patch.object(
|
||||
Moulinette.interface, "prompt", return_value="some_value"
|
||||
) as prompt:
|
||||
_parse_args_in_yunohost_format(answers, questions)
|
||||
assert ask_text in prompt.call_args[0][0]
|
||||
assert help_text in prompt.call_args[0][0]
|
||||
|
@ -462,7 +470,9 @@ def test_parse_args_in_yunohost_format_password_input_test_ask():
|
|||
]
|
||||
answers = {}
|
||||
|
||||
with patch.object(Moulinette.interface, "prompt", return_value="some_value") as prompt:
|
||||
with patch.object(
|
||||
Moulinette.interface, "prompt", return_value="some_value"
|
||||
) as prompt:
|
||||
_parse_args_in_yunohost_format(answers, questions)
|
||||
prompt.assert_called_with(ask_text, True)
|
||||
|
||||
|
@ -481,7 +491,9 @@ def test_parse_args_in_yunohost_format_password_input_test_ask_with_example():
|
|||
]
|
||||
answers = {}
|
||||
|
||||
with patch.object(Moulinette.interface, "prompt", return_value="some_value") as prompt:
|
||||
with patch.object(
|
||||
Moulinette.interface, "prompt", return_value="some_value"
|
||||
) as prompt:
|
||||
_parse_args_in_yunohost_format(answers, questions)
|
||||
assert ask_text in prompt.call_args[0][0]
|
||||
assert example_text in prompt.call_args[0][0]
|
||||
|
@ -501,7 +513,9 @@ def test_parse_args_in_yunohost_format_password_input_test_ask_with_help():
|
|||
]
|
||||
answers = {}
|
||||
|
||||
with patch.object(Moulinette.interface, "prompt", return_value="some_value") as prompt:
|
||||
with patch.object(
|
||||
Moulinette.interface, "prompt", return_value="some_value"
|
||||
) as prompt:
|
||||
_parse_args_in_yunohost_format(answers, questions)
|
||||
assert ask_text in prompt.call_args[0][0]
|
||||
assert help_text in prompt.call_args[0][0]
|
||||
|
@ -697,7 +711,9 @@ def test_parse_args_in_yunohost_format_path_input_test_ask():
|
|||
]
|
||||
answers = {}
|
||||
|
||||
with patch.object(Moulinette.interface, "prompt", return_value="some_value") as prompt:
|
||||
with patch.object(
|
||||
Moulinette.interface, "prompt", return_value="some_value"
|
||||
) as prompt:
|
||||
_parse_args_in_yunohost_format(answers, questions)
|
||||
prompt.assert_called_with(ask_text, False)
|
||||
|
||||
|
@ -715,7 +731,9 @@ def test_parse_args_in_yunohost_format_path_input_test_ask_with_default():
|
|||
]
|
||||
answers = {}
|
||||
|
||||
with patch.object(Moulinette.interface, "prompt", return_value="some_value") as prompt:
|
||||
with patch.object(
|
||||
Moulinette.interface, "prompt", return_value="some_value"
|
||||
) as prompt:
|
||||
_parse_args_in_yunohost_format(answers, questions)
|
||||
prompt.assert_called_with("%s (default: %s)" % (ask_text, default_text), False)
|
||||
|
||||
|
@ -734,7 +752,9 @@ def test_parse_args_in_yunohost_format_path_input_test_ask_with_example():
|
|||
]
|
||||
answers = {}
|
||||
|
||||
with patch.object(Moulinette.interface, "prompt", return_value="some_value") as prompt:
|
||||
with patch.object(
|
||||
Moulinette.interface, "prompt", return_value="some_value"
|
||||
) as prompt:
|
||||
_parse_args_in_yunohost_format(answers, questions)
|
||||
assert ask_text in prompt.call_args[0][0]
|
||||
assert example_text in prompt.call_args[0][0]
|
||||
|
@ -754,7 +774,9 @@ def test_parse_args_in_yunohost_format_path_input_test_ask_with_help():
|
|||
]
|
||||
answers = {}
|
||||
|
||||
with patch.object(Moulinette.interface, "prompt", return_value="some_value") as prompt:
|
||||
with patch.object(
|
||||
Moulinette.interface, "prompt", return_value="some_value"
|
||||
) as prompt:
|
||||
_parse_args_in_yunohost_format(answers, questions)
|
||||
assert ask_text in prompt.call_args[0][0]
|
||||
assert help_text in prompt.call_args[0][0]
|
||||
|
|
|
@ -7,6 +7,7 @@ from yunohost.tools import tools_adminpw
|
|||
from moulinette import m18n
|
||||
from moulinette.core import MoulinetteError
|
||||
|
||||
|
||||
def setup_function(function):
|
||||
|
||||
if os.system("systemctl is-active slapd") != 0:
|
||||
|
|
|
@ -56,7 +56,7 @@ def _get_ldap_interface():
|
|||
def _ldap_path_extract(path, info):
|
||||
for element in path.split(","):
|
||||
if element.startswith(info + "="):
|
||||
return element[len(info + "="):]
|
||||
return element[len(info + "=") :]
|
||||
|
||||
|
||||
# Add this to properly close / delete the ldap interface / authenticator
|
||||
|
@ -72,8 +72,7 @@ def _destroy_ldap_interface():
|
|||
atexit.register(_destroy_ldap_interface)
|
||||
|
||||
|
||||
class LDAPInterface():
|
||||
|
||||
class LDAPInterface:
|
||||
def __init__(self):
|
||||
logger.debug("initializing ldap interface")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue