def test_remove_report_crd_failure(caplog):
fake_http_resp = FakeHTTPResponse(500, "{\"message\":\"fake message\"}",
"{\"reason\":\"WrongReason\"}")
fake_api_exception = K8sApiException(http_resp=fake_http_resp)
fake_crd_report = MagicMock()
fake_crd_report.remove.side_effect = fake_api_exception
with patch('kubernetes.config.load_incluster_config',
MagicMock(return_value=0)),\
patch('kubernetes.client.ExtensionsV1beta1Api',
MagicMock(return_value=0)), \
patch.object(custom_resource.CustomResourceDefinitionType,
'create',
MagicMock(return_value=fake_crd_report)):
with pytest.raises(SystemExit):
uninstall.remove_report_crd("cmk-nodereport", ["cmk-nr"])
caplog_tuple = caplog.record_tuples
exp_err = "Aborting uninstall: " \
"Exception when removing custom resource definition " \
"\"cmk-nodereport\""
exp_log_err = get_expected_log_error(exp_err, fake_http_resp)
assert caplog_tuple[-1][2] == exp_log_err
test_uninstall.py 文件源码
python
阅读 16
收藏 0
点赞 0
评论 0
评论列表
文章目录