test_apprise.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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,
  12. byte_capacity=100,
  13. log_level=1,
  14. ),
  15. )
  16. module.destroy_monitor(
  17. hook_config=flexmock(),
  18. config=flexmock(),
  19. monitoring_log_level=1,
  20. dry_run=False,
  21. )
  22. assert logger.handlers == original_handlers
  23. def test_destroy_monitor_without_apprise_handler_does_not_raise():
  24. logger = logging.getLogger()
  25. original_handlers = list(logger.handlers)
  26. # Don't mess with the actual log level because it can impact downstream tests.
  27. flexmock(logger).should_receive('setLevel')
  28. module.destroy_monitor(
  29. hook_config=flexmock(),
  30. config=flexmock(),
  31. monitoring_log_level=1,
  32. dry_run=False,
  33. )
  34. assert logger.handlers == original_handlers