test_apprise.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import logging
  2. from flexmock import flexmock
  3. from borgmatic.hooks.monitoring import apprise as module
  4. def test_destroy_monitor_removes_apprise_handler():
  5. logger = logging.getLogger()
  6. original_handlers = list(logger.handlers)
  7. # Don't mess with the actual log level because it can impact downstream tests.
  8. flexmock(logger).should_receive('setLevel')
  9. module.borgmatic.hooks.monitoring.logs.add_handler(
  10. module.borgmatic.hooks.monitoring.logs.Forgetful_buffering_handler(
  11. identifier=module.HANDLER_IDENTIFIER, byte_capacity=100, log_level=1
  12. )
  13. )
  14. module.destroy_monitor(
  15. hook_config=flexmock(), config=flexmock(), monitoring_log_level=1, dry_run=False
  16. )
  17. assert logger.handlers == original_handlers
  18. def test_destroy_monitor_without_apprise_handler_does_not_raise():
  19. logger = logging.getLogger()
  20. original_handlers = list(logger.handlers)
  21. # Don't mess with the actual log level because it can impact downstream tests.
  22. flexmock(logger).should_receive('setLevel')
  23. module.destroy_monitor(
  24. hook_config=flexmock(), config=flexmock(), monitoring_log_level=1, dry_run=False
  25. )
  26. assert logger.handlers == original_handlers