def test_perform_http_healthcheck_failure(mock_http_conn): fake_http_url = "http://fakehost:1234/fake_status_path" fake_timeout = 10 mock_http_conn.return_value = mock.Mock(status_code=400, headers={}) assert not perform_http_healthcheck(fake_http_url, fake_timeout) mock_http_conn.assert_called_once_with(fake_http_url)
def test_perform_http_healthcheck_failure_with_multiple_content_type(mock_http_conn): fake_http_url = "http://fakehost:1234/fake_status_path" fake_timeout = 10 mock_http_conn.return_value = mock.Mock( status_code=200, headers={'content-type': 'fake_content_type_1, fake_content_type_2'}) assert not perform_http_healthcheck(fake_http_url, fake_timeout) mock_http_conn.assert_called_once_with(fake_http_url)
def test_perform_http_healthcheck_timeout(mock_http_conn): fake_http_url = "http://fakehost:1234/fake_status_path" fake_timeout = 10 actual = perform_http_healthcheck(fake_http_url, fake_timeout) assert actual[0] is False assert "10" in actual[1] assert "timed out" in actual[1] mock_http_conn.assert_called_once_with(fake_http_url)
def test_perform_http_healthcheck_timeout(mock_http_conn): fake_http_url = "http://fakehost:1234/fake_status_path" fake_timeout = 10 assert not perform_http_healthcheck(fake_http_url, fake_timeout) mock_http_conn.assert_called_once_with(fake_http_url)