mock_get_metrics.assert_called_once()
+@asynctest.mock.patch("n2vc.libjuju.Libjuju.get_controller")
+@asynctest.mock.patch("n2vc.libjuju.Libjuju.get_model")
+@asynctest.mock.patch("n2vc.libjuju.Libjuju.get_executed_actions")
+@asynctest.mock.patch("n2vc.libjuju.Libjuju.get_actions")
+@asynctest.mock.patch("n2vc.libjuju.Libjuju.get_application_configs")
+@asynctest.mock.patch("n2vc.libjuju.Libjuju._get_application")
+class UpdateVcaStatusTest(N2VCJujuConnTestCase):
+ def setUp(self):
+ super(UpdateVcaStatusTest, self).setUp()
+
+ def test_success(
+ self,
+ mock_get_application,
+ mock_get_application_configs,
+ mock_get_actions,
+ mock_get_executed_actions,
+ mock_get_model,
+ mock_get_controller,
+ ):
+ self.loop.run_until_complete(self.n2vc.update_vca_status(
+ {"model": {"applications": {"app": {"actions": {}}}}}))
+ mock_get_executed_actions.assert_called_once()
+ mock_get_actions.assert_called_once()
+ mock_get_application_configs.assert_called_once()
+
+ def test_exception(
+ self,
+ mock_get_application,
+ mock_get_application_configs,
+ mock_get_actions,
+ mock_get_executed_actions,
+ mock_get_model,
+ mock_get_controller,
+ ):
+ mock_get_model.return_value = None
+ mock_get_executed_actions.side_effect = Exception()
+ with self.assertRaises(Exception):
+ self.loop.run_until_complete(self.n2vc.update_vca_status(
+ {"model": {"applications": {"app": {"actions": {}}}}}))
+ mock_get_executed_actions.assert_not_called()
+ mock_get_actions.assert_not_called_once()
+ mock_get_application_configs.assert_not_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
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_deploy_charm,
mock_path,
mock_file_exists,
+ mock_model_exists,
):
mock_k8s_cloud.return_value = None
with self.assertRaises(JujuK8sProxycharmNotSupported):
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(
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(
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):
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()