Merge pull request #1300 from YunoHost/ci-format-dev

[CI] Format code
This commit is contained in:
Alexandre Aubin 2021-08-28 02:03:08 +02:00 committed by GitHub
commit 0ccc0b63e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 16 deletions

View file

@ -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:

View file

@ -81,7 +81,8 @@ def pytest_cmdline_main(config):
import yunohost
yunohost.init(debug=config.option.yunodebug)
class DummyInterface():
class DummyInterface:
type = "test"

View file

@ -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]

View file

@ -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:

View file

@ -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")