# 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
class KubectlTestCase(TestCase):
- def setUp(self,):
+ def setUp(
+ self,
+ ):
pass
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):
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()
def test_get_configuration(self, mock_load_kube_config, mock_configuration):
kubectl = Kubectl()
- kubectl.get_configuration()
+ kubectl.configuration
mock_configuration.assert_called_once()