test_healthchecks.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. from flexmock import flexmock
  2. from borgmatic.hooks import healthchecks as module
  3. def test_ping_healthchecks_hits_ping_url():
  4. ping_url = 'https://example.com'
  5. flexmock(module.requests).should_receive('get').with_args(ping_url)
  6. module.ping_healthchecks(ping_url, 'config.yaml', dry_run=False)
  7. def test_ping_healthchecks_without_ping_url_does_not_raise():
  8. flexmock(module.requests).should_receive('get').never()
  9. module.ping_healthchecks(ping_url_or_uuid=None, config_filename='config.yaml', dry_run=False)
  10. def test_ping_healthchecks_with_ping_uuid_hits_corresponding_url():
  11. ping_uuid = 'abcd-efgh-ijkl-mnop'
  12. flexmock(module.requests).should_receive('get').with_args(
  13. 'https://hc-ping.com/{}'.format(ping_uuid)
  14. )
  15. module.ping_healthchecks(ping_uuid, 'config.yaml', dry_run=False)
  16. def test_ping_healthchecks_hits_ping_url_with_append():
  17. ping_url = 'https://example.com'
  18. append = 'failed-so-hard'
  19. flexmock(module.requests).should_receive('get').with_args('{}/{}'.format(ping_url, append))
  20. module.ping_healthchecks(ping_url, 'config.yaml', dry_run=False, append=append)