renamed push_monitor back to ping_monitor in uptime kuma hook
Some checks are pending
build / test (push) Waiting to run
build / docs (push) Blocked by required conditions

This commit is contained in:
Paul Wilde 2024-06-26 20:57:37 +01:00
parent d108e6102b
commit 067c79c606
2 changed files with 21 additions and 21 deletions

View file

@ -14,7 +14,7 @@ def initialize_monitor(
pass 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. Make a get request to the configured Uptime Kuma push_url.
Use the given configuration filename in any log entries. Use the given configuration filename in any log entries.

View file

@ -7,13 +7,13 @@ DEFAULT_PUSH_URL = 'https://example.uptime.kuma/api/push/abcd1234'
CUSTOM_PUSH_URL = 'https://uptime.example.com/api/push/efgh5678' 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 = {} hook_config = {}
flexmock(module.requests).should_receive('get').with_args( flexmock(module.requests).should_receive('get').with_args(
f'{DEFAULT_PUSH_URL}?status=down&msg=fail' f'{DEFAULT_PUSH_URL}?status=down&msg=fail'
).and_return(flexmock(ok=True)).once() ).and_return(flexmock(ok=True)).once()
module.push_monitor( module.ping_monitor(
hook_config, hook_config,
{}, {},
'config.yaml', '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} hook_config = {'push_url': CUSTOM_PUSH_URL}
flexmock(module.requests).should_receive('get').with_args( flexmock(module.requests).should_receive('get').with_args(
f'{CUSTOM_PUSH_URL}?status=down&msg=fail' f'{CUSTOM_PUSH_URL}?status=down&msg=fail'
).and_return(flexmock(ok=True)).once() ).and_return(flexmock(ok=True)).once()
module.push_monitor( module.ping_monitor(
hook_config, hook_config,
{}, {},
'config.yaml', '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} hook_config = {'push_url': CUSTOM_PUSH_URL}
flexmock(module.requests).should_receive('get').with_args( flexmock(module.requests).should_receive('get').with_args(
f'{CUSTOM_PUSH_URL}?status=up&msg=start' f'{CUSTOM_PUSH_URL}?status=up&msg=start'
).and_return(flexmock(ok=True)).once() ).and_return(flexmock(ok=True)).once()
module.push_monitor( module.ping_monitor(
hook_config, hook_config,
{}, {},
'config.yaml', '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} hook_config = {'push_url': CUSTOM_PUSH_URL}
flexmock(module.requests).should_receive('get').with_args( flexmock(module.requests).should_receive('get').with_args(
f'{CUSTOM_PUSH_URL}?status=up&msg=finish' f'{CUSTOM_PUSH_URL}?status=up&msg=finish'
).and_return(flexmock(ok=True)).once() ).and_return(flexmock(ok=True)).once()
module.push_monitor( module.ping_monitor(
hook_config, hook_config,
{}, {},
'config.yaml', '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} hook_config = {'push_url': CUSTOM_PUSH_URL}
flexmock(module.requests).should_receive('get').never() flexmock(module.requests).should_receive('get').never()
module.push_monitor( module.ping_monitor(
hook_config, hook_config,
{}, {},
'config.yaml', '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} hook_config = {'push_url': CUSTOM_PUSH_URL}
flexmock(module.requests).should_receive('get').never() flexmock(module.requests).should_receive('get').never()
module.push_monitor( module.ping_monitor(
hook_config, hook_config,
{}, {},
'config.yaml', '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} hook_config = {'push_url': CUSTOM_PUSH_URL}
flexmock(module.requests).should_receive('get').never() flexmock(module.requests).should_receive('get').never()
module.push_monitor( module.ping_monitor(
hook_config, hook_config,
{}, {},
'config.yaml', '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} hook_config = {'push_url': CUSTOM_PUSH_URL}
flexmock(module.requests).should_receive('get').with_args( flexmock(module.requests).should_receive('get').with_args(
f'{CUSTOM_PUSH_URL}?status=down&msg=fail' f'{CUSTOM_PUSH_URL}?status=down&msg=fail'
).and_raise(module.requests.exceptions.ConnectionError) ).and_raise(module.requests.exceptions.ConnectionError)
flexmock(module.logger).should_receive('warning').once() flexmock(module.logger).should_receive('warning').once()
module.push_monitor( module.ping_monitor(
hook_config, hook_config,
{}, {},
'config.yaml', '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} hook_config = {'push_url': CUSTOM_PUSH_URL}
response = flexmock(ok=False) response = flexmock(ok=False)
response.should_receive('raise_for_status').and_raise( response.should_receive('raise_for_status').and_raise(
@ -141,7 +141,7 @@ def test_push_monitor_with_other_error_logs_warning():
).and_return(response) ).and_return(response)
flexmock(module.logger).should_receive('warning').once() flexmock(module.logger).should_receive('warning').once()
module.push_monitor( module.ping_monitor(
hook_config, hook_config,
{}, {},
'config.yaml', '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} hook_config = {'push_url': CUSTOM_PUSH_URL}
flexmock(module.requests).should_receive('get').never() flexmock(module.requests).should_receive('get').never()
module.push_monitor( module.ping_monitor(
hook_config, hook_config,
{}, {},
'config.yaml', 'config.yaml',