|
@@ -62,13 +62,13 @@ def test_format_buffered_logs_for_payload_without_handler_produces_empty_payload
|
|
|
|
|
|
def test_ping_monitor_hits_ping_url_for_start_state():
|
|
|
flexmock(module).should_receive('Forgetful_buffering_handler')
|
|
|
- ping_url = 'https://example.com'
|
|
|
+ hook_config = {'ping_url': 'https://example.com'}
|
|
|
flexmock(module.requests).should_receive('post').with_args(
|
|
|
- '{}/{}'.format(ping_url, 'start'), data=''.encode('utf-8')
|
|
|
+ 'https://example.com/start', data=''.encode('utf-8')
|
|
|
)
|
|
|
|
|
|
module.ping_monitor(
|
|
|
- ping_url,
|
|
|
+ hook_config,
|
|
|
'config.yaml',
|
|
|
state=module.monitor.State.START,
|
|
|
monitoring_log_level=1,
|
|
@@ -77,15 +77,15 @@ def test_ping_monitor_hits_ping_url_for_start_state():
|
|
|
|
|
|
|
|
|
def test_ping_monitor_hits_ping_url_for_finish_state():
|
|
|
- ping_url = 'https://example.com'
|
|
|
+ hook_config = {'ping_url': 'https://example.com'}
|
|
|
payload = 'data'
|
|
|
flexmock(module).should_receive('format_buffered_logs_for_payload').and_return(payload)
|
|
|
flexmock(module.requests).should_receive('post').with_args(
|
|
|
- ping_url, data=payload.encode('utf-8')
|
|
|
+ 'https://example.com', data=payload.encode('utf-8')
|
|
|
)
|
|
|
|
|
|
module.ping_monitor(
|
|
|
- ping_url,
|
|
|
+ hook_config,
|
|
|
'config.yaml',
|
|
|
state=module.monitor.State.FINISH,
|
|
|
monitoring_log_level=1,
|
|
@@ -94,15 +94,15 @@ def test_ping_monitor_hits_ping_url_for_finish_state():
|
|
|
|
|
|
|
|
|
def test_ping_monitor_hits_ping_url_for_fail_state():
|
|
|
- ping_url = 'https://example.com'
|
|
|
+ hook_config = {'ping_url': 'https://example.com'}
|
|
|
payload = 'data'
|
|
|
flexmock(module).should_receive('format_buffered_logs_for_payload').and_return(payload)
|
|
|
flexmock(module.requests).should_receive('post').with_args(
|
|
|
- '{}/{}'.format(ping_url, 'fail'), data=payload.encode('utf')
|
|
|
+ 'https://example.com/fail', data=payload.encode('utf')
|
|
|
)
|
|
|
|
|
|
module.ping_monitor(
|
|
|
- ping_url,
|
|
|
+ hook_config,
|
|
|
'config.yaml',
|
|
|
state=module.monitor.State.FAIL,
|
|
|
monitoring_log_level=1,
|
|
@@ -111,15 +111,15 @@ def test_ping_monitor_hits_ping_url_for_fail_state():
|
|
|
|
|
|
|
|
|
def test_ping_monitor_with_ping_uuid_hits_corresponding_url():
|
|
|
- ping_uuid = 'abcd-efgh-ijkl-mnop'
|
|
|
+ hook_config = {'ping_url': 'abcd-efgh-ijkl-mnop'}
|
|
|
payload = 'data'
|
|
|
flexmock(module).should_receive('format_buffered_logs_for_payload').and_return(payload)
|
|
|
flexmock(module.requests).should_receive('post').with_args(
|
|
|
- 'https://hc-ping.com/{}'.format(ping_uuid), data=payload.encode('utf-8')
|
|
|
+ 'https://hc-ping.com/{}'.format(hook_config['ping_url']), data=payload.encode('utf-8')
|
|
|
)
|
|
|
|
|
|
module.ping_monitor(
|
|
|
- ping_uuid,
|
|
|
+ hook_config,
|
|
|
'config.yaml',
|
|
|
state=module.monitor.State.FINISH,
|
|
|
monitoring_log_level=1,
|
|
@@ -129,11 +129,11 @@ def test_ping_monitor_with_ping_uuid_hits_corresponding_url():
|
|
|
|
|
|
def test_ping_monitor_dry_run_does_not_hit_ping_url():
|
|
|
flexmock(module).should_receive('Forgetful_buffering_handler')
|
|
|
- ping_url = 'https://example.com'
|
|
|
+ hook_config = {'ping_url': 'https://example.com'}
|
|
|
flexmock(module.requests).should_receive('post').never()
|
|
|
|
|
|
module.ping_monitor(
|
|
|
- ping_url,
|
|
|
+ hook_config,
|
|
|
'config.yaml',
|
|
|
state=module.monitor.State.START,
|
|
|
monitoring_log_level=1,
|