def test_ping_monitor_dry_run_does_not_hit_ping_url(): flexmock(module).should_receive('Forgetful_buffering_handler') ping_url = 'https://example.com' flexmock(module.requests).should_receive('post').never() module.ping_monitor( ping_url, 'config.yaml', state=module.monitor.State.START, monitoring_log_level=1, dry_run=True, )
def test_ping_monitor_hits_ping_url_for_start_state(): flexmock(module).should_receive('Forgetful_buffering_handler') ping_url = 'https://example.com' flexmock(module.requests).should_receive('post').with_args( '{}/{}'.format(ping_url, 'start'), data=''.encode('utf-8') ) module.ping_monitor( ping_url, 'config.yaml', state=module.monitor.State.START, monitoring_log_level=1, dry_run=False, )
def test_ping_monitor_hits_ping_url_for_fail_state(): 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') ) module.ping_monitor( ping_url, 'config.yaml', state=module.monitor.State.FAIL, monitoring_log_level=1, dry_run=False, )
def test_ping_monitor_with_ping_uuid_hits_corresponding_url(): ping_uuid = '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') ) module.ping_monitor( ping_uuid, 'config.yaml', state=module.monitor.State.FINISH, monitoring_log_level=1, dry_run=False, )