Bug 1962 fixed: removed the variable cluster_uuid from init_env method
[osm/N2VC.git] / n2vc / tests / unit / test_k8s_helm_conn.py
index 8e58740..a6515f1 100644 (file)
@@ -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,