borgmatic/tests/unit/test_verbosity.py

25 lines
869 B
Python
Raw Normal View History

2017-10-26 07:36:23 +02:00
import logging
from flexmock import flexmock
2017-10-26 07:36:23 +02:00
from borgmatic import verbosity as module
def insert_logging_mock(log_level):
'''
Mock the isEnabledFor from Python logging.
'''
logging = flexmock(module.logging.Logger)
logging.should_receive('isEnabledFor').replace_with(lambda level: level >= log_level)
logging.should_receive('getEffectiveLevel').replace_with(lambda: log_level)
2017-10-26 07:36:23 +02:00
def test_verbosity_to_log_level_maps_known_verbosity_to_log_level():
assert module.verbosity_to_log_level(module.VERBOSITY_SOME) == logging.INFO
assert module.verbosity_to_log_level(module.VERBOSITY_LOTS) == logging.DEBUG
2019-11-03 09:55:19 +01:00
assert module.verbosity_to_log_level(module.VERBOSITY_ERROR) == logging.ERROR
2017-10-26 07:36:23 +02:00
def test_verbosity_to_log_level_maps_unknown_verbosity_to_warning_level():
assert module.verbosity_to_log_level('my pants') == logging.WARNING