Corrected bugs on support for helm v3
[osm/N2VC.git] / n2vc / tests / unit / test_kubectl.py
index 8fb0310..28d66c5 100644 (file)
@@ -13,7 +13,7 @@
 #     limitations under the License.
 
 from unittest import TestCase, mock
-from n2vc.kubectl import Kubectl
+from n2vc.kubectl import Kubectl, CORE_CLIENT
 from n2vc.utils import Dict
 from kubernetes.client.rest import ApiException
 
@@ -114,7 +114,9 @@ fake_list_services = Dict(
 
 
 class KubectlTestCase(TestCase):
-    def setUp(self,):
+    def setUp(
+        self,
+    ):
         pass
 
 
@@ -123,7 +125,7 @@ class FakeCoreV1Api:
         return fake_list_services
 
 
-class ProvisionerTest(TestCase):
+class GetServices(TestCase):
     @mock.patch("n2vc.kubectl.config.load_kube_config")
     @mock.patch("n2vc.kubectl.client.CoreV1Api")
     def setUp(self, mock_core, mock_config):
@@ -140,9 +142,10 @@ class ProvisionerTest(TestCase):
         keys = ["name", "cluster_ip", "type", "ports", "external_ip"]
         self.assertTrue(k in service for service in services for k in keys)
 
-    @mock.patch("n2vc.kubectl.client.CoreV1Api.list_service_for_all_namespaces")
-    def test_get_service_exception(self, list_services):
-        list_services.side_effect = ApiException()
+    def test_get_service_exception(self):
+        self.kubectl.clients[
+            CORE_CLIENT
+        ].list_service_for_all_namespaces.side_effect = ApiException()
         with self.assertRaises(ApiException):
             self.kubectl.get_services()
 
@@ -155,7 +158,7 @@ class GetConfiguration(KubectlTestCase):
 
     def test_get_configuration(self, mock_load_kube_config, mock_configuration):
         kubectl = Kubectl()
-        kubectl.get_configuration()
+        kubectl.configuration
         mock_configuration.assert_called_once()