test_pagerduty.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from flexmock import flexmock
  2. from borgmatic.hooks import pagerduty as module
  3. def test_ping_monitor_ignores_start_state():
  4. flexmock(module.requests).should_receive('post').never()
  5. module.ping_monitor(
  6. 'abc123', 'config.yaml', module.monitor.State.START, monitoring_log_level=1, dry_run=False
  7. )
  8. def test_ping_monitor_ignores_finish_state():
  9. flexmock(module.requests).should_receive('post').never()
  10. module.ping_monitor(
  11. 'abc123', 'config.yaml', module.monitor.State.FINISH, monitoring_log_level=1, dry_run=False
  12. )
  13. def test_ping_monitor_calls_api_for_fail_state():
  14. flexmock(module.requests).should_receive('post')
  15. module.ping_monitor(
  16. 'abc123', 'config.yaml', module.monitor.State.FAIL, monitoring_log_level=1, dry_run=False
  17. )
  18. def test_ping_monitor_dry_run_does_not_call_api():
  19. flexmock(module.requests).should_receive('post').never()
  20. module.ping_monitor(
  21. 'abc123', 'config.yaml', module.monitor.State.FAIL, monitoring_log_level=1, dry_run=True
  22. )