test_cronhub.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. from flexmock import flexmock
  2. from borgmatic.hooks import cronhub as module
  3. def test_ping_cronhub_hits_ping_url_with_start_state():
  4. ping_url = 'https://example.com/start/abcdef'
  5. state = 'bork'
  6. flexmock(module.requests).should_receive('get').with_args('https://example.com/bork/abcdef')
  7. module.ping_cronhub(ping_url, 'config.yaml', dry_run=False, state=state)
  8. def test_ping_cronhub_hits_ping_url_with_ping_state():
  9. ping_url = 'https://example.com/ping/abcdef'
  10. state = 'bork'
  11. flexmock(module.requests).should_receive('get').with_args('https://example.com/bork/abcdef')
  12. module.ping_cronhub(ping_url, 'config.yaml', dry_run=False, state=state)
  13. def test_ping_cronhub_without_ping_url_does_not_raise():
  14. flexmock(module.requests).should_receive('get').never()
  15. module.ping_cronhub(ping_url=None, config_filename='config.yaml', dry_run=False, state='oops')
  16. def test_ping_cronhub_dry_run_does_not_hit_ping_url():
  17. ping_url = 'https://example.com'
  18. flexmock(module.requests).should_receive('get').never()
  19. module.ping_cronhub(ping_url, 'config.yaml', dry_run=True, state='yay')