From 067c79c606ebffa4fba698a5eef6461f592b523a Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Wed, 26 Jun 2024 20:57:37 +0100 Subject: [PATCH] renamed push_monitor back to ping_monitor in uptime kuma hook --- borgmatic/hooks/uptimekuma.py | 2 +- tests/unit/hooks/test_uptimekuma.py | 40 ++++++++++++++--------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/borgmatic/hooks/uptimekuma.py b/borgmatic/hooks/uptimekuma.py index ca9f4ca..75731be 100644 --- a/borgmatic/hooks/uptimekuma.py +++ b/borgmatic/hooks/uptimekuma.py @@ -14,7 +14,7 @@ def initialize_monitor( pass -def push_monitor(hook_config, config, config_filename, state, monitoring_log_level, dry_run): +def ping_monitor(hook_config, config, config_filename, state, monitoring_log_level, dry_run): ''' Make a get request to the configured Uptime Kuma push_url. Use the given configuration filename in any log entries. diff --git a/tests/unit/hooks/test_uptimekuma.py b/tests/unit/hooks/test_uptimekuma.py index fa77b92..05d5802 100644 --- a/tests/unit/hooks/test_uptimekuma.py +++ b/tests/unit/hooks/test_uptimekuma.py @@ -7,13 +7,13 @@ DEFAULT_PUSH_URL = 'https://example.uptime.kuma/api/push/abcd1234' CUSTOM_PUSH_URL = 'https://uptime.example.com/api/push/efgh5678' -def test_push_monitor_hits_default_uptimekuma_on_fail(): +def test_ping_monitor_hits_default_uptimekuma_on_fail(): hook_config = {} flexmock(module.requests).should_receive('get').with_args( f'{DEFAULT_PUSH_URL}?status=down&msg=fail' ).and_return(flexmock(ok=True)).once() - module.push_monitor( + module.ping_monitor( hook_config, {}, 'config.yaml', @@ -23,13 +23,13 @@ def test_push_monitor_hits_default_uptimekuma_on_fail(): ) -def test_push_monitor_hits_custom_uptimekuma_on_fail(): +def test_ping_monitor_hits_custom_uptimekuma_on_fail(): hook_config = {'push_url': CUSTOM_PUSH_URL} flexmock(module.requests).should_receive('get').with_args( f'{CUSTOM_PUSH_URL}?status=down&msg=fail' ).and_return(flexmock(ok=True)).once() - module.push_monitor( + module.ping_monitor( hook_config, {}, 'config.yaml', @@ -39,13 +39,13 @@ def test_push_monitor_hits_custom_uptimekuma_on_fail(): ) -def test_push_monitor_custom_uptimekuma_on_start(): +def test_ping_monitor_custom_uptimekuma_on_start(): hook_config = {'push_url': CUSTOM_PUSH_URL} flexmock(module.requests).should_receive('get').with_args( f'{CUSTOM_PUSH_URL}?status=up&msg=start' ).and_return(flexmock(ok=True)).once() - module.push_monitor( + module.ping_monitor( hook_config, {}, 'config.yaml', @@ -55,13 +55,13 @@ def test_push_monitor_custom_uptimekuma_on_start(): ) -def test_push_monitor_custom_uptimekuma_on_finish(): +def test_ping_monitor_custom_uptimekuma_on_finish(): hook_config = {'push_url': CUSTOM_PUSH_URL} flexmock(module.requests).should_receive('get').with_args( f'{CUSTOM_PUSH_URL}?status=up&msg=finish' ).and_return(flexmock(ok=True)).once() - module.push_monitor( + module.ping_monitor( hook_config, {}, 'config.yaml', @@ -71,11 +71,11 @@ def test_push_monitor_custom_uptimekuma_on_finish(): ) -def test_push_monitor_does_not_hit_custom_uptimekuma_on_fail_dry_run(): +def test_ping_monitor_does_not_hit_custom_uptimekuma_on_fail_dry_run(): hook_config = {'push_url': CUSTOM_PUSH_URL} flexmock(module.requests).should_receive('get').never() - module.push_monitor( + module.ping_monitor( hook_config, {}, 'config.yaml', @@ -85,11 +85,11 @@ def test_push_monitor_does_not_hit_custom_uptimekuma_on_fail_dry_run(): ) -def test_push_monitor_does_not_hit_custom_uptimekuma_on_start_dry_run(): +def test_ping_monitor_does_not_hit_custom_uptimekuma_on_start_dry_run(): hook_config = {'push_url': CUSTOM_PUSH_URL} flexmock(module.requests).should_receive('get').never() - module.push_monitor( + module.ping_monitor( hook_config, {}, 'config.yaml', @@ -99,11 +99,11 @@ def test_push_monitor_does_not_hit_custom_uptimekuma_on_start_dry_run(): ) -def test_push_monitor_does_not_hit_custom_uptimekuma_on_finish_dry_run(): +def test_ping_monitor_does_not_hit_custom_uptimekuma_on_finish_dry_run(): hook_config = {'push_url': CUSTOM_PUSH_URL} flexmock(module.requests).should_receive('get').never() - module.push_monitor( + module.ping_monitor( hook_config, {}, 'config.yaml', @@ -113,14 +113,14 @@ def test_push_monitor_does_not_hit_custom_uptimekuma_on_finish_dry_run(): ) -def test_push_monitor_with_connection_error_logs_warning(): +def test_ping_monitor_with_connection_error_logs_warning(): hook_config = {'push_url': CUSTOM_PUSH_URL} flexmock(module.requests).should_receive('get').with_args( f'{CUSTOM_PUSH_URL}?status=down&msg=fail' ).and_raise(module.requests.exceptions.ConnectionError) flexmock(module.logger).should_receive('warning').once() - module.push_monitor( + module.ping_monitor( hook_config, {}, 'config.yaml', @@ -130,7 +130,7 @@ def test_push_monitor_with_connection_error_logs_warning(): ) -def test_push_monitor_with_other_error_logs_warning(): +def test_ping_monitor_with_other_error_logs_warning(): hook_config = {'push_url': CUSTOM_PUSH_URL} response = flexmock(ok=False) response.should_receive('raise_for_status').and_raise( @@ -141,7 +141,7 @@ def test_push_monitor_with_other_error_logs_warning(): ).and_return(response) flexmock(module.logger).should_receive('warning').once() - module.push_monitor( + module.ping_monitor( hook_config, {}, 'config.yaml', @@ -151,11 +151,11 @@ def test_push_monitor_with_other_error_logs_warning(): ) -def test_push_monitor_with_invalid_run_state(): +def test_ping_monitor_with_invalid_run_state(): hook_config = {'push_url': CUSTOM_PUSH_URL} flexmock(module.requests).should_receive('get').never() - module.push_monitor( + module.ping_monitor( hook_config, {}, 'config.yaml',