X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=n2vc%2Ftests%2Funit%2Ftest_k8s_helm_conn.py;fp=n2vc%2Ftests%2Funit%2Ftest_k8s_helm_conn.py;h=a6515f1f879cf50701270bd7e6575fd2bdd54997;hp=8e587401052819b832562b54af2c2864fd1cf368;hb=b41de17df6282334088ffbd887fbc01e496e1797;hpb=156677967e417604682fda05ed0099f07f1a3129 diff --git a/n2vc/tests/unit/test_k8s_helm_conn.py b/n2vc/tests/unit/test_k8s_helm_conn.py index 8e58740..a6515f1 100644 --- a/n2vc/tests/unit/test_k8s_helm_conn.py +++ b/n2vc/tests/unit/test_k8s_helm_conn.py @@ -38,7 +38,7 @@ class TestK8sHelmConn(asynctest.TestCase): self.namespace = "testk8s" self.service_account = "osm" self.cluster_id = "helm_cluster_id" - self.cluster_uuid = "{}:{}".format(self.namespace, self.cluster_id) + self.cluster_uuid = self.cluster_id # pass fake kubectl and helm commands to make sure it does not call actual commands K8sHelmConnector._check_file_exists = asynctest.Mock(return_value=True) K8sHelmConnector._local_async_exec = asynctest.CoroutineMock( @@ -585,6 +585,7 @@ class TestK8sHelmConn(asynctest.TestCase): "updated": "2020-10-30 11:11:20.376744191 +0000 UTC", } ] + self.helm_conn._get_namespace = Mock(return_value=self.namespace) self.helm_conn._uninstall_sw = asynctest.CoroutineMock() self.helm_conn.instances_list = asynctest.CoroutineMock(return_value=instances) self.helm_conn.uninstall = asynctest.CoroutineMock() @@ -594,6 +595,9 @@ class TestK8sHelmConn(asynctest.TestCase): self.helm_conn.fs.file_delete.assert_called_once_with( self.cluster_id, ignore_non_exist=True ) + self.helm_conn._get_namespace.assert_called_once_with( + cluster_uuid=self.cluster_uuid + ) self.helm_conn.instances_list.assert_called_once_with( cluster_uuid=self.cluster_uuid ) @@ -601,7 +605,7 @@ class TestK8sHelmConn(asynctest.TestCase): cluster_uuid=self.cluster_uuid, kdu_instance=kdu_instance ) self.helm_conn._uninstall_sw.assert_called_once_with( - self.cluster_id, self.namespace + cluster_id=self.cluster_id, namespace=self.namespace ) @asynctest.fail_on(active_handles=True) @@ -636,8 +640,10 @@ class TestK8sHelmConn(asynctest.TestCase): ) call2_kargs = calls[2][1] command_2 = ( - "/usr/bin/kubectl --kubeconfig={} --namespace kube-system delete " - "serviceaccount/{}".format(self.kube_config, self.service_account) + "/usr/bin/kubectl --kubeconfig={} --namespace {} delete " + "serviceaccount/{}".format( + self.kube_config, self.namespace, self.service_account + ) ) self.assertEqual( call2_kargs,