Moaaaar lint/test fixes

This commit is contained in:
Alexandre Aubin 2021-08-27 19:45:07 +02:00
parent 3c4520a6d8
commit b0fd78657e
4 changed files with 6 additions and 11 deletions

View file

@ -554,7 +554,7 @@ class Interface:
return value return value
def display(self, message, style="info"): # m18n: info def display(self, message, style="info"): # i18n: info
"""Display a message""" """Display a message"""
if style == "success": if style == "success":
print("{} {}".format(colorize(m18n.g("success"), "green"), message)) print("{} {}".format(colorize(m18n.g("success"), "green"), message))

View file

@ -21,6 +21,6 @@ class Authenticator(BaseAuthenticator):
def _authenticate_credentials(self, credentials=None): def _authenticate_credentials(self, credentials=None):
if not credentials == self.name: if not credentials == self.name:
raise MoulinetteError("invalid_password") raise MoulinetteError("invalid_password", raw_msg=True)
return return

View file

@ -21,6 +21,6 @@ class Authenticator(BaseAuthenticator):
def _authenticate_credentials(self, credentials=None): def _authenticate_credentials(self, credentials=None):
if not credentials == self.name: if not credentials == self.name:
raise MoulinetteError("invalid_password") raise MoulinetteError("invalid_password", raw_msg=True)
return return

View file

@ -217,17 +217,14 @@ class TestAuthCLI:
with pytest.raises(MoulinetteError) as exception: with pytest.raises(MoulinetteError) as exception:
moulinette_cli.run(["testauth", "other-profile"], output_as="none") moulinette_cli.run(["testauth", "other-profile"], output_as="none")
translation = m18n.g("invalid_password") assert "invalid_password" in str(exception)
expected_msg = translation.format()
assert expected_msg in str(exception)
mocker.patch("os.isatty", return_value=True) mocker.patch("os.isatty", return_value=True)
mocker.patch("getpass.getpass", return_value="yoloswag") mocker.patch("getpass.getpass", return_value="yoloswag")
with pytest.raises(MoulinetteError) as exception: with pytest.raises(MoulinetteError) as exception:
moulinette_cli.run(["testauth", "default"], output_as="none") moulinette_cli.run(["testauth", "default"], output_as="none")
expected_msg = translation.format() assert "invalid_password" in str(exception)
assert expected_msg in str(exception)
def test_request_no_auth_needed(self, capsys, moulinette_cli): def test_request_no_auth_needed(self, capsys, moulinette_cli):
moulinette_cli.run(["testauth", "none"], output_as="plain") moulinette_cli.run(["testauth", "none"], output_as="plain")
@ -259,9 +256,7 @@ class TestAuthCLI:
message = capsys.readouterr() message = capsys.readouterr()
assert "some_data_from_only_cli" not in message.out assert "some_data_from_only_cli" not in message.out
translation = m18n.g("invalid_password") assert "invalid_password" in str(exception)
expected_msg = translation.format()
assert expected_msg in str(exception)
def test_request_with_callback(self, moulinette_cli, capsys, mocker): def test_request_with_callback(self, moulinette_cli, capsys, mocker):
mocker.patch("os.isatty", return_value=True) mocker.patch("os.isatty", return_value=True)