Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[68] Add additional flake8 checks #130

Merged
merged 3 commits into from
Apr 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions hamster_cli/hamster_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ def _ensure_directory_exists(self, directory):
return directory


AppDirs = HamsterAppDirs('hamster_cli')


class Controler(HamsterControl):
def __init__(self):
"""Instantiate controler instance and adding client_config to it."""
Expand All @@ -141,6 +138,17 @@ def __init__(self):
self.client_config = client_config


LOG_LEVELS = {
'info': logging.INFO,
'debug': logging.DEBUG,
'warning': logging.WARNING,
'error': logging.ERROR,
}


AppDirs = HamsterAppDirs('hamster_cli')


pass_controler = click.make_pass_decorator(Controler, ensure=True)


Expand Down Expand Up @@ -642,12 +650,6 @@ def get_logfile_path():
return os.path.join(log_dir, config.get('Client', 'log_filename'))

def get_log_level():
LOG_LEVELS = {
'info': logging.INFO,
'debug': logging.DEBUG,
'warning': logging.WARNING,
'error': logging.ERROR,
}
try:
log_level = LOG_LEVELS[config.get('Client', 'log_level').lower()]
except KeyError:
Expand Down
10 changes: 5 additions & 5 deletions tests/test_hamster_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def test_setup_logging(self, controler, client_config, lib_config):
assert controler.client_logger.level == (
controler.client_config['log_level'])

def test_setup_logging_log_console_True(self, controler):
def test_setup_logging_log_console_true(self, controler):
"""Make sure that if console loggin is on lib and client logger have a streamhandler."""
controler.client_config['log_console'] = True
hamster_cli._setup_logging(controler)
Expand All @@ -256,7 +256,7 @@ def test_setup_logging_no_logging(self, controler):
assert controler.lib_logger.handlers == []
assert controler.client_logger.handlers == []

def test_setup_logging_log_file_True(self, controler, appdirs):
def test_setup_logging_log_file_true(self, controler, appdirs):
"""Make sure that if we enable a logfile_path, both loggers recieve a ``FileHandler``."""
controler.client_config['logfile_path'] = os.path.join(appdirs.user_log_dir, 'foobar.log')
hamster_cli._setup_logging(controler)
Expand Down Expand Up @@ -348,17 +348,17 @@ def test_header(self):


class TestWriteConfigFile(object):
def test_file_is_written(request, filepath):
def test_file_is_written(self, filepath):
"""Make sure the file is written. Content is not checked, this is ConfigParsers job."""
hamster_cli._write_config_file(filepath)
assert os.path.lexists(filepath)

def test_return_config_instance(request, filepath):
def test_return_config_instance(self, filepath):
"""Make sure we return a ``SafeConfigParser`` instance."""
result = hamster_cli._write_config_file(filepath)
assert isinstance(result, SafeConfigParser)

def test_non_existing_path(request, tmpdir, filename):
def test_non_existing_path(self, tmpdir, filename):
"""Make sure that the path-parents are created ifnot present."""
filepath = os.path.join(tmpdir.strpath, 'foobar')
assert os.path.lexists(filepath) is False
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ commands =

[testenv:flake8]
basepython = python3.4
deps = flake8==2.5.4
deps =
flake8==2.5.4
flake8-debugger==1.4.0
flake8-print==2.0.2
pep8-naming==0.3.3
skip_install = True
commands = flake8 setup.py hamster_cli/ tests/

Expand Down