test_cronitor.py 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. from flexmock import flexmock
  2. from borgmatic.hooks import cronitor as module
  3. def test_ping_monitor_hits_ping_url_for_start_state():
  4. ping_url = 'https://example.com'
  5. flexmock(module.requests).should_receive('get').with_args('{}/{}'.format(ping_url, 'run'))
  6. module.ping_monitor(ping_url, 'config.yaml', module.monitor.State.START, dry_run=False)
  7. def test_ping_monitor_hits_ping_url_for_finish_state():
  8. ping_url = 'https://example.com'
  9. flexmock(module.requests).should_receive('get').with_args('{}/{}'.format(ping_url, 'complete'))
  10. module.ping_monitor(ping_url, 'config.yaml', module.monitor.State.FINISH, dry_run=False)
  11. def test_ping_monitor_hits_ping_url_for_fail_state():
  12. ping_url = 'https://example.com'
  13. flexmock(module.requests).should_receive('get').with_args('{}/{}'.format(ping_url, 'fail'))
  14. module.ping_monitor(ping_url, 'config.yaml', module.monitor.State.FAIL, dry_run=False)
  15. def test_ping_monitor_dry_run_does_not_hit_ping_url():
  16. ping_url = 'https://example.com'
  17. flexmock(module.requests).should_receive('get').never()
  18. module.ping_monitor(ping_url, 'config.yaml', module.monitor.State.START, dry_run=True)