Bug 1980 fixed
[osm/N2VC.git] / n2vc / tests / unit / test_k8s_helm3_conn.py
index 4f5247b..91e1729 100644 (file)
@@ -39,7 +39,7 @@ class TestK8sHelm3Conn(asynctest.TestCase):
         self.fs.path = "./tmp/"
         self.namespace = "testk8s"
         self.cluster_id = "helm3_cluster_id"
         self.fs.path = "./tmp/"
         self.namespace = "testk8s"
         self.cluster_id = "helm3_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
         K8sHelm3Connector._check_file_exists = asynctest.Mock(return_value=True)
         cluster_dir = self.fs.path + self.cluster_id
         # pass fake kubectl and helm commands to make sure it does not call actual commands
         K8sHelm3Connector._check_file_exists = asynctest.Mock(return_value=True)
         cluster_dir = self.fs.path + self.cluster_id
@@ -66,8 +66,8 @@ class TestK8sHelm3Conn(asynctest.TestCase):
 
         self.assertEqual(
             k8scluster_uuid,
 
         self.assertEqual(
             k8scluster_uuid,
-            "{}:{}".format(self.namespace, self.cluster_id),
-            "Check cluster_uuid format: <namespace>.<cluster_id>",
+            self.cluster_id,
+            "Check cluster_uuid",
         )
         self.helm_conn._get_namespaces.assert_called_once_with(self.cluster_id)
         self.helm_conn._create_namespace.assert_called_once_with(
         )
         self.helm_conn._get_namespaces.assert_called_once_with(self.cluster_id)
         self.helm_conn._create_namespace.assert_called_once_with(
@@ -574,7 +574,7 @@ class TestK8sHelm3Conn(asynctest.TestCase):
         self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
 
         await self.helm_conn._status_kdu(
         self.helm_conn._local_async_exec = asynctest.CoroutineMock(return_value=("", 0))
 
         await self.helm_conn._status_kdu(
-            self.cluster_id, kdu_instance, self.namespace, return_text=True
+            self.cluster_id, kdu_instance, self.namespace, yaml_format=True
         )
         command = (
             "env KUBECONFIG=./tmp/helm3_cluster_id/.kube/config /usr/bin/helm3 status {} --namespace={} --output yaml"
         )
         command = (
             "env KUBECONFIG=./tmp/helm3_cluster_id/.kube/config /usr/bin/helm3 status {} --namespace={} --output yaml"
@@ -617,7 +617,7 @@ class TestK8sHelm3Conn(asynctest.TestCase):
             cluster_id=self.cluster_id,
             kdu_instance=kdu_instance,
             namespace=self.namespace,
             cluster_id=self.cluster_id,
             kdu_instance=kdu_instance,
             namespace=self.namespace,
-            return_text=False,
+            yaml_format=False,
         )
         self.helm_conn.write_app_status_to_db.assert_called_once_with(
             db_dict=db_dict,
         )
         self.helm_conn.write_app_status_to_db.assert_called_once_with(
             db_dict=db_dict,
@@ -651,6 +651,7 @@ class TestK8sHelm3Conn(asynctest.TestCase):
                 "updated": "2020-10-30 11:11:20.376744191 +0000 UTC",
             }
         ]
                 "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()
         self.helm_conn._uninstall_sw = asynctest.CoroutineMock()
         self.helm_conn.instances_list = asynctest.CoroutineMock(return_value=instances)
         self.helm_conn.uninstall = asynctest.CoroutineMock()
@@ -660,6 +661,9 @@ class TestK8sHelm3Conn(asynctest.TestCase):
         self.helm_conn.fs.file_delete.assert_called_once_with(
             self.cluster_id, ignore_non_exist=True
         )
         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
         )
         self.helm_conn.instances_list.assert_called_once_with(
             cluster_uuid=self.cluster_uuid
         )
@@ -667,7 +671,7 @@ class TestK8sHelm3Conn(asynctest.TestCase):
             cluster_uuid=self.cluster_uuid, kdu_instance=kdu_instance
         )
         self.helm_conn._uninstall_sw.assert_called_once_with(
             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)
         )
 
     @asynctest.fail_on(active_handles=True)