krkn_lib.tests.test_krkn_openshift module
Comprehensive tests for KrknOpenshift class.
This test suite includes both unit tests (mocked) and integration tests (requiring actual testdata or clusters).
Unit tests use mocks to test all methods without requiring actual OpenShift clusters or external services.
Integration tests use BaseTest and require actual testdata files or cluster connections.
Assisted By: Claude Code
- class krkn_lib.tests.test_krkn_openshift.KrknOpenshiftIntegrationTest(methodName='runTest')
Bases:
BaseTestIntegration tests requiring actual cluster connections.
- test_filter_must_gather_ocp_log_folder()
Test log filtering with actual testdata files.
- test_get_cloud_infrastructure()
Test cloud infrastructure detection on real cluster.
- test_get_cluster_network_plugins()
Test network plugin detection on real cluster.
- test_get_cluster_type()
Test cluster type detection on real cluster.
- test_get_cluster_version_string()
Test cluster version string retrieval on real cluster.
- test_is_openshift()
Test OpenShift detection on real cluster.
- class krkn_lib.tests.test_krkn_openshift.TestCollectFilterArchiveOcpLogs(methodName='runTest')
Bases:
TestCaseTest collect_filter_archive_ocp_logs method.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test_collect_filter_archive_ocp_logs_expands_tilde(mock_which, mock_exists, mock_expanduser)
Test tilde expansion in paths.
- test_collect_filter_archive_ocp_logs_invalid_kubeconfig(mock_which, mock_exists)
Test with invalid kubeconfig path.
- test_collect_filter_archive_ocp_logs_oc_not_found(mock_which)
Test when oc command is not found.
- class krkn_lib.tests.test_krkn_openshift.TestFilterMustGatherOcpLogFolder(methodName='runTest')
Bases:
TestCaseTest filter_must_gather_ocp_log_folder method.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test_filter_must_gather_ocp_log_folder_dst_not_exists()
Test when destination directory doesn’t exist.
- class krkn_lib.tests.test_krkn_openshift.TestGetCloudInfrastructure(methodName='runTest')
Bases:
TestCaseTest get_cloud_infrastructure method.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test_get_cloud_infrastructure_aws(mock_api_client_prop)
Test getting AWS infrastructure.
- test_get_cloud_infrastructure_exception(mock_api_client_prop)
Test exception handling returns Unknown.
- test_get_cloud_infrastructure_no_api_client(mock_api_client_prop)
Test when api_client is None.
- class krkn_lib.tests.test_krkn_openshift.TestGetClusterNetworkPlugins(methodName='runTest')
Bases:
TestCaseTest get_cluster_network_plugins method.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test_get_cluster_network_plugins_exception(mock_api_client_prop)
Test exception handling returns Unknown.
- test_get_cluster_network_plugins_no_api_client(mock_api_client_prop)
Test when api_client is None.
- test_get_cluster_network_plugins_ovn(mock_api_client_prop)
Test getting OVNKubernetes network plugin.
- class krkn_lib.tests.test_krkn_openshift.TestGetClusterType(methodName='runTest')
Bases:
TestCaseTest get_cluster_type method with PropertyMock.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test_get_cluster_type_exception(mock_api_client_prop)
Test exception handling returns self-managed.
- test_get_cluster_type_no_api_client(mock_api_client_prop)
Test when api_client is None.
- test_get_cluster_type_rosa(mock_api_client_prop)
Test getting ROSA cluster type from resource tags.
- test_get_cluster_type_self_managed(mock_api_client_prop)
Test getting self-managed cluster type (no resource tags).
- class krkn_lib.tests.test_krkn_openshift.TestGetClusterversionString(methodName='runTest')
Bases:
TestCaseTest get_clusterversion_string method.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test_get_clusterversion_string_empty(mock_get_clusterversion_string)
Test when clusterversion string is empty.
- test_get_clusterversion_string_success(mock_get_clusterversion_string)
Test successful retrieval of clusterversion string.
- class krkn_lib.tests.test_krkn_openshift.TestGetPrometheusApiConnectionData(methodName='runTest')
Bases:
TestCaseTest get_prometheus_api_connection_data method.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test_get_prometheus_api_connection_data_no_token(mock_create_token)
Test when token creation fails.
- test_get_prometheus_api_connection_data_route_not_found(mock_create_token, mock_api_client_prop)
Test when prometheus route is not found.
- test_get_prometheus_api_connection_data_success(mock_create_token, mock_api_client_prop)
Test successful retrieval of Prometheus connection data.
- class krkn_lib.tests.test_krkn_openshift.TestIsOpenshift(methodName='runTest')
Bases:
TestCaseTest is_openshift method.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test_is_openshift_false_empty(mock_get_clusterversion_string)
Test is_openshift returns False when version is empty.
- test_is_openshift_false_none(mock_get_clusterversion_string)
Test is_openshift returns False when version is None.
- test_is_openshift_true(mock_get_clusterversion_string)
Test is_openshift returns True for OpenShift cluster.
- class krkn_lib.tests.test_krkn_openshift.TestKrknOpenshiftInit(methodName='runTest')
Bases:
TestCaseTest KrknOpenshift initialization.
- test_init_with_kubeconfig(mock_config)
Test initialization with kubeconfig path.
- test_init_without_kubeconfig(mock_config)
Test initialization without kubeconfig path.