X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=n2vc%2Ftests%2Funit%2Ftest_kubectl.py;h=28d66c530df30f2020332cd93e508c601b38019c;hp=8fb0310ca41173d1848cb35097490971e6f70ffe;hb=refs%2Fchanges%2F47%2F10047%2F13;hpb=1c83f2e4d061ad37ba898e114cb42e70fdee5145 diff --git a/n2vc/tests/unit/test_kubectl.py b/n2vc/tests/unit/test_kubectl.py index 8fb0310..28d66c5 100644 --- a/n2vc/tests/unit/test_kubectl.py +++ b/n2vc/tests/unit/test_kubectl.py @@ -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()