def test_discover_add_taint_failure1(caplog): fake_http_resp = FakeHTTPResponse(500, "fake reason", "fake body") fake_api_exception = K8sApiException(http_resp=fake_http_resp) with patch('intel.discover.get_k8s_node', MagicMock(side_effect=fake_api_exception)): with pytest.raises(SystemExit): discover.add_node_taint() exp_err = "Exception when getting the node obj" exp_log_err = get_expected_log_error(exp_err) caplog_tuple = caplog.record_tuples assert caplog_tuple[0][2] == exp_log_err
def test_discover_add_taint_failure2(caplog): fake_node_resp = {"metadata": {"annotations": {}}} fake_http_resp = FakeHTTPResponse(500, "fake reason", "fake body") fake_api_exception = K8sApiException(http_resp=fake_http_resp) with patch('intel.discover.get_k8s_node', MagicMock(return_value=fake_node_resp)), \ patch('intel.discover.patch_k8s_node', MagicMock(side_effect=fake_api_exception)): with pytest.raises(SystemExit): discover.add_node_taint() exp_err = "Exception when tainting the node" exp_log_err = get_expected_log_error(exp_err) caplog_tuple = caplog.record_tuples assert caplog_tuple[0][2] == exp_log_err