projects
/
osm
/
N2VC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix bug 2060: Add logic to delete models gracefully
[osm/N2VC.git]
/
n2vc
/
tests
/
unit
/
test_kubectl.py
diff --git
a/n2vc/tests/unit/test_kubectl.py
b/n2vc/tests/unit/test_kubectl.py
index
8fb0310
..
eb9b01d
100644
(file)
--- 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
# 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
from n2vc.utils import Dict
from kubernetes.client.rest import ApiException
@@
-114,7
+114,9
@@
fake_list_services = Dict(
class KubectlTestCase(TestCase):
class KubectlTestCase(TestCase):
- def setUp(self,):
+ def setUp(
+ self,
+ ):
pass
pass
@@
-123,7
+125,7
@@
class FakeCoreV1Api:
return fake_list_services
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):
@mock.patch("n2vc.kubectl.config.load_kube_config")
@mock.patch("n2vc.kubectl.client.CoreV1Api")
def setUp(self, mock_core, mock_config):
@@
-140,23
+142,34
@@
class ProvisionerTest(TestCase):
keys = ["name", "cluster_ip", "type", "ports", "external_ip"]
self.assertTrue(k in service for service in services for k in keys)
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()
with self.assertRaises(ApiException):
self.kubectl.get_services()
-@mock.patch("kubernetes.config.kube_config.Configuration")
+@mock.patch("n2vc.kubectl.client")
+@mock.patch("n2vc.kubectl.config.kube_config.Configuration.get_default_copy")
@mock.patch("n2vc.kubectl.config.load_kube_config")
class GetConfiguration(KubectlTestCase):
def setUp(self):
super(GetConfiguration, self).setUp()
@mock.patch("n2vc.kubectl.config.load_kube_config")
class GetConfiguration(KubectlTestCase):
def setUp(self):
super(GetConfiguration, self).setUp()
- def test_get_configuration(self, mock_load_kube_config, mock_configuration):
+ def test_get_configuration(
+ self,
+ mock_load_kube_config,
+ mock_configuration,
+ mock_client,
+ ):
kubectl = Kubectl()
kubectl = Kubectl()
- kubectl.
get_configuration()
+ kubectl.
configuration
mock_configuration.assert_called_once()
mock_configuration.assert_called_once()
+ mock_load_kube_config.assert_called_once()
+ mock_client.CoreV1Api.assert_called_once()
+ mock_client.RbacAuthorizationV1Api.assert_called_once()
+ mock_client.StorageV1Api.assert_called_once()
@mock.patch("kubernetes.client.StorageV1Api.list_storage_class")
@mock.patch("kubernetes.client.StorageV1Api.list_storage_class")