test_verbosity.py 869 B

123456789101112131415161718192021222324
  1. import logging
  2. from flexmock import flexmock
  3. from borgmatic import verbosity as module
  4. def insert_logging_mock(log_level):
  5. '''
  6. Mock the isEnabledFor from Python logging.
  7. '''
  8. logging = flexmock(module.logging.Logger)
  9. logging.should_receive('isEnabledFor').replace_with(lambda level: level >= log_level)
  10. logging.should_receive('getEffectiveLevel').replace_with(lambda: log_level)
  11. def test_verbosity_to_log_level_maps_known_verbosity_to_log_level():
  12. assert module.verbosity_to_log_level(module.VERBOSITY_SOME) == logging.INFO
  13. assert module.verbosity_to_log_level(module.VERBOSITY_LOTS) == logging.DEBUG
  14. assert module.verbosity_to_log_level(module.VERBOSITY_ERROR) == logging.ERROR
  15. def test_verbosity_to_log_level_maps_unknown_verbosity_to_warning_level():
  16. assert module.verbosity_to_log_level('my pants') == logging.WARNING