test_cronhub.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from flexmock import flexmock
  2. from borgmatic.hooks import cronhub as module
  3. def test_ping_monitor_rewrites_ping_url_for_start_state():
  4. ping_url = 'https://example.com/start/abcdef'
  5. flexmock(module.requests).should_receive('get').with_args('https://example.com/start/abcdef')
  6. module.ping_monitor(ping_url, 'config.yaml', module.monitor.State.START, dry_run=False)
  7. def test_ping_monitor_rewrites_ping_url_and_state_for_start_state():
  8. ping_url = 'https://example.com/ping/abcdef'
  9. flexmock(module.requests).should_receive('get').with_args('https://example.com/start/abcdef')
  10. module.ping_monitor(ping_url, 'config.yaml', module.monitor.State.START, dry_run=False)
  11. def test_ping_monitor_rewrites_ping_url_for_finish_state():
  12. ping_url = 'https://example.com/start/abcdef'
  13. flexmock(module.requests).should_receive('get').with_args('https://example.com/finish/abcdef')
  14. module.ping_monitor(ping_url, 'config.yaml', module.monitor.State.FINISH, dry_run=False)
  15. def test_ping_monitor_rewrites_ping_url_for_fail_state():
  16. ping_url = 'https://example.com/start/abcdef'
  17. flexmock(module.requests).should_receive('get').with_args('https://example.com/fail/abcdef')
  18. module.ping_monitor(ping_url, 'config.yaml', module.monitor.State.FAIL, dry_run=False)
  19. def test_ping_monitor_dry_run_does_not_hit_ping_url():
  20. ping_url = 'https://example.com'
  21. flexmock(module.requests).should_receive('get').never()
  22. module.ping_monitor(ping_url, 'config.yaml', module.monitor.State.START, dry_run=True)