Fix bug 1467
[osm/N2VC.git] / n2vc / tests / unit / test_n2vc_juju_conn.py
index bad5fc3..64b93cc 100644 (file)
@@ -81,6 +81,7 @@ class GetMetricssTest(N2VCJujuConnTestCase):
         mock_get_metrics.assert_called_once()
 
 
         mock_get_metrics.assert_called_once()
 
 
+@asynctest.mock.patch("n2vc.libjuju.Libjuju.model_exists")
 @asynctest.mock.patch("osm_common.fslocal.FsLocal.file_exists")
 @asynctest.mock.patch(
     "osm_common.fslocal.FsLocal.path", new_callable=asynctest.PropertyMock, create=True
 @asynctest.mock.patch("osm_common.fslocal.FsLocal.file_exists")
 @asynctest.mock.patch(
     "osm_common.fslocal.FsLocal.path", new_callable=asynctest.PropertyMock, create=True
@@ -92,8 +93,9 @@ class K8sProxyCharmsTest(N2VCJujuConnTestCase):
         super(K8sProxyCharmsTest, self).setUp()
 
     def test_success(
         super(K8sProxyCharmsTest, self).setUp()
 
     def test_success(
-        self, mock_add_model, mock_deploy_charm, mock_path, mock_file_exists,
+        self, mock_add_model, mock_deploy_charm, mock_path, mock_file_exists, mock_model_exists
     ):
     ):
+        mock_model_exists.return_value = None
         mock_file_exists.return_value = True
         mock_path.return_value = "/path"
         ee_id = self.loop.run_until_complete(
         mock_file_exists.return_value = True
         mock_path.return_value = "/path"
         ee_id = self.loop.run_until_complete(
@@ -131,6 +133,7 @@ class K8sProxyCharmsTest(N2VCJujuConnTestCase):
         mock_deploy_charm,
         mock_path,
         mock_file_exists,
         mock_deploy_charm,
         mock_path,
         mock_file_exists,
+        mock_model_exists,
     ):
         mock_k8s_cloud.return_value = None
         with self.assertRaises(JujuK8sProxycharmNotSupported):
     ):
         mock_k8s_cloud.return_value = None
         with self.assertRaises(JujuK8sProxycharmNotSupported):
@@ -142,7 +145,7 @@ class K8sProxyCharmsTest(N2VCJujuConnTestCase):
             self.assertIsNone(ee_id)
 
     def test_no_artifact_path(
             self.assertIsNone(ee_id)
 
     def test_no_artifact_path(
-        self, mock_add_model, mock_deploy_charm, mock_path, mock_file_exists,
+        self, mock_add_model, mock_deploy_charm, mock_path, mock_file_exists, mock_model_exists,
     ):
         with self.assertRaises(N2VCBadArgumentsException):
             ee_id = self.loop.run_until_complete(
     ):
         with self.assertRaises(N2VCBadArgumentsException):
             ee_id = self.loop.run_until_complete(
@@ -153,7 +156,7 @@ class K8sProxyCharmsTest(N2VCJujuConnTestCase):
             self.assertIsNone(ee_id)
 
     def test_no_db(
             self.assertIsNone(ee_id)
 
     def test_no_db(
-        self, mock_add_model, mock_deploy_charm, mock_path, mock_file_exists,
+        self, mock_add_model, mock_deploy_charm, mock_path, mock_file_exists, mock_model_exists,
     ):
         with self.assertRaises(N2VCBadArgumentsException):
             ee_id = self.loop.run_until_complete(
     ):
         with self.assertRaises(N2VCBadArgumentsException):
             ee_id = self.loop.run_until_complete(
@@ -164,7 +167,7 @@ class K8sProxyCharmsTest(N2VCJujuConnTestCase):
             self.assertIsNone(ee_id)
 
     def test_file_not_exists(
             self.assertIsNone(ee_id)
 
     def test_file_not_exists(
-        self, mock_add_model, mock_deploy_charm, mock_path, mock_file_exists,
+        self, mock_add_model, mock_deploy_charm, mock_path, mock_file_exists, mock_model_exists,
     ):
         mock_file_exists.return_value = False
         with self.assertRaises(N2VCBadArgumentsException):
     ):
         mock_file_exists.return_value = False
         with self.assertRaises(N2VCBadArgumentsException):
@@ -176,8 +179,9 @@ class K8sProxyCharmsTest(N2VCJujuConnTestCase):
             self.assertIsNone(ee_id)
 
     def test_exception(
             self.assertIsNone(ee_id)
 
     def test_exception(
-        self, mock_add_model, mock_deploy_charm, mock_path, mock_file_exists,
+        self, mock_add_model, mock_deploy_charm, mock_path, mock_file_exists, mock_model_exists,
     ):
     ):
+        mock_model_exists.return_value = None
         mock_file_exists.return_value = True
         mock_path.return_value = "/path"
         mock_deploy_charm.side_effect = Exception()
         mock_file_exists.return_value = True
         mock_path.return_value = "/path"
         mock_deploy_charm.side_effect = Exception()