Skip to content

Commit 0beb253

Browse files
author
pintaoz
committed
Add unit test
1 parent 7d51071 commit 0beb253

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/unit_tests/clients/test_kubernetes_client.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,3 +661,27 @@ def test_get_cluster_queue(
661661
plural="clusterqueues",
662662
name="test-cluster-queue",
663663
)
664+
665+
@patch(
666+
"kubernetes.client.CoreV1Api",
667+
return_value=Mock(
668+
read_namespace=Mock(
669+
return_value=V1Namespace(metadata=V1ObjectMeta(name="test"))
670+
)
671+
),
672+
)
673+
def test_check_if_namespace_exists_true(self, mock_core_client: Mock):
674+
test_client = KubernetesClient()
675+
result = test_client.check_if_namespace_exists("kubeflow")
676+
self.assertTrue(result)
677+
678+
@patch(
679+
"kubernetes.client.CoreV1Api",
680+
side_effect=client.rest.ApiException(
681+
status=404,
682+
),
683+
)
684+
def test_check_if_namespace_exists_false(self, mock_core_client: Mock):
685+
test_client = KubernetesClient()
686+
result = test_client.check_if_namespace_exists("abcdef")
687+
self.assertFalse(result)

0 commit comments

Comments
 (0)