Skip to content

Commit

Permalink
make flake8 happy
Browse files Browse the repository at this point in the history
  • Loading branch information
kay0u committed Jan 2, 2020
1 parent 1cfec24 commit 247411c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion moulinette/authenticators/ldap.py
Expand Up @@ -117,7 +117,7 @@ def _hash_user_password(password):

# we aren't using sha-512 but something else that is weaker, proceed to upgrade
if not hashed_password["userPassword"][0].startswith("{CRYPT}$6$"):
self.update("cn=admin", {"userPassword": _hash_user_password(password),})
self.update("cn=admin", {"userPassword": _hash_user_password(password)})

# Additional LDAP methods
# TODO: Review these methods
Expand Down
12 changes: 11 additions & 1 deletion moulinette/utils/log.py
Expand Up @@ -16,6 +16,16 @@
CRITICAL,
)

__all__ = [
"NOTSET", # noqa
"DEBUG",
"INFO",
"WARNING",
"ERROR",
"CRITICAL",
"SUCCESS",
]


# Global configuration and functions -----------------------------------

Expand All @@ -35,7 +45,7 @@
"stream": "ext://sys.stdout",
},
},
"loggers": {"moulinette": {"level": "DEBUG", "handlers": ["console"],},},
"loggers": {"moulinette": {"level": "DEBUG", "handlers": ["console"]}},
}


Expand Down
6 changes: 3 additions & 3 deletions test/conftest.py
Expand Up @@ -55,7 +55,7 @@ def patch_logging(moulinette):
"format": "%(asctime)-15s %(levelname)-8s %(name)s %(funcName)s - %(fmessage)s" # noqa
},
},
"filters": {"action": {"()": "moulinette.utils.log.ActionFilter",},},
"filters": {"action": {"()": "moulinette.utils.log.ActionFilter"}},
"handlers": {
"api": {
"level": level,
Expand All @@ -68,14 +68,14 @@ def patch_logging(moulinette):
},
},
"loggers": {
"moulinette": {"level": level, "handlers": [], "propagate": True,},
"moulinette": {"level": level, "handlers": [], "propagate": True},
"moulinette.interface": {
"level": level,
"handlers": handlers,
"propagate": False,
},
},
"root": {"level": level, "handlers": root_handlers,},
"root": {"level": level, "handlers": root_handlers},
}


Expand Down
2 changes: 1 addition & 1 deletion test/test_actionsmap.py
Expand Up @@ -284,4 +284,4 @@ def test_actions_map_cli():
assert 'testauth' in amap.parser._subparsers.choices
assert 'none' in amap.parser._subparsers.choices['testauth']._actions[1].choices
assert 'subcat' in amap.parser._subparsers.choices['testauth']._actions[1].choices
assert 'default' in amap.parser._subparsers.choices['testauth']._actions[1].choices['subcat']._actions[1].choices
assert 'default' in amap.parser._subparsers.choices['testauth']._actions[1].choices['subcat']._actions[1].choices
2 changes: 0 additions & 2 deletions test/test_auth.py
@@ -1,6 +1,5 @@
import os
import pytest
import json

from moulinette import MoulinetteError
from moulinette import m18n
Expand Down Expand Up @@ -79,7 +78,6 @@ def test_login_bad_password(self, moulinette_webapi):
assert "session.id" not in moulinette_webapi.cookies
assert "session.tokens" not in moulinette_webapi.cookies


def test_login_csrf_attempt(self, moulinette_webapi):
# C.f.
# https://security.stackexchange.com/a/58308
Expand Down
3 changes: 1 addition & 2 deletions test/test_filesystem.py
Expand Up @@ -4,8 +4,6 @@
import pwd
import grp

from stat import *

from moulinette import m18n
from moulinette.core import MoulinetteError
from moulinette.utils.filesystem import (
Expand Down Expand Up @@ -158,6 +156,7 @@ def test_read_ldif_cannot_exception(test_ldif, mocker):
expected_msg = translation.format(file=str(test_ldif), error=error)
assert expected_msg in str(exception)


def test_write_to_existing_file(test_file):
write_to_file(str(test_file), "yolo\nswag")
assert read_file(str(test_file)) == "yolo\nswag"
Expand Down
9 changes: 8 additions & 1 deletion test/test_process.py
Expand Up @@ -25,20 +25,23 @@ def callback(a, b, c):
assert isinstance(b, str)
assert isinstance(c, str)
return True

assert run_commands(["yolo swag", "yolo swag", "yolo swag"], callback=callback) == 3

def callback(a, b, c):
assert isinstance(a, int)
assert isinstance(b, str)
assert isinstance(c, str)
return False

assert run_commands(["yolo swag", "yolo swag"], callback=callback) == 1

def callback(a, b, c):
assert isinstance(a, int)
assert isinstance(b, str)
assert isinstance(c, tuple)
return True

run_commands(["yolo swag"], separate_stderr=True, callback=callback)


Expand All @@ -62,18 +65,20 @@ def test_run_shell_kwargs():


def test_call_async_output(test_file):

def callback(a):
assert a == "foo\n" or a == "bar\n"

call_async_output(["cat", str(test_file)], callback)

with pytest.raises(ValueError):
call_async_output(["cat", str(test_file)], 1)

def callbackA(a):
assert a == "foo\n" or a == "bar\n"

def callbackB(a):
pass

callback = (callbackA, callbackB)
call_async_output(["cat", str(test_file)], callback)

Expand All @@ -91,8 +96,10 @@ def callback(a):

def callbackA(a):
assert a == "foo\n" or a == "bar\n"

def callbackB(a):
pass

def callbackC(a):
pass

Expand Down

0 comments on commit 247411c

Please sign in to comment.