test_verbosity.py 776 B

123456789101112131415161718192021
  1. import logging
  2. from flexmock import flexmock
  3. from borgmatic import verbosity as module
  4. def insert_logging_mock(log_level):
  5. """ Mocks the isEnabledFor from python logging. """
  6. logging = flexmock(module.logging.Logger)
  7. logging.should_receive('isEnabledFor').replace_with(lambda lvl: lvl >= log_level)
  8. logging.should_receive('getEffectiveLevel').replace_with(lambda: log_level)
  9. def test_verbosity_to_log_level_maps_known_verbosity_to_log_level():
  10. assert module.verbosity_to_log_level(module.VERBOSITY_SOME) == logging.INFO
  11. assert module.verbosity_to_log_level(module.VERBOSITY_LOTS) == logging.DEBUG
  12. def test_verbosity_to_log_level_maps_unknown_verbosity_to_warning_level():
  13. assert module.verbosity_to_log_level('my pants') == logging.WARNING