From: ksaikiranr Date: Wed, 17 Mar 2021 07:24:15 +0000 (+0530) Subject: Feature-9904: Enhancing NG-UI to enable Juju operational view dashboard X-Git-Tag: branch-sol006v331-start~2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F96%2F10496%2F3;p=osm%2FN2VC.git Feature-9904: Enhancing NG-UI to enable Juju operational view dashboard Added unit test for update_vca_status method for KNF Change-Id: Iba6285d0d5deeaa7bef685a22abeba0ae535ab19 Signed-off-by: jayaramans Signed-off-by: ksaikiranr --- diff --git a/n2vc/tests/unit/test_k8s_juju_conn.py b/n2vc/tests/unit/test_k8s_juju_conn.py index b182d8c..f454380 100644 --- a/n2vc/tests/unit/test_k8s_juju_conn.py +++ b/n2vc/tests/unit/test_k8s_juju_conn.py @@ -789,3 +789,31 @@ class GetCredentialsTest(K8sJujuConnTestCase): self.k8s_juju_conn.db.get_one.assert_called_once() self.k8s_juju_conn.db.encrypt_decrypt_fields.assert_called_once() mock_safe_dump.assert_called_once() + + +class UpdateVcaStatusTest(K8sJujuConnTestCase): + def setUp(self): + super(UpdateVcaStatusTest, self).setUp() + self.vcaStatus = {"model": {"applications": {"app": {"actions": {}}}}} + self.kdu_name = "kdu_name" + self.kdu_instance = "{}-{}".format(self.kdu_name, "id") + self.k8s_juju_conn.libjuju.get_executed_actions = AsyncMock() + self.k8s_juju_conn.libjuju.get_actions = AsyncMock() + self.k8s_juju_conn.libjuju.get_application_configs = AsyncMock() + + def test_success(self): + self.loop.run_until_complete(self.k8s_juju_conn.update_vca_status( + self.vcaStatus, self.kdu_instance)) + self.k8s_juju_conn.libjuju.get_executed_actions.assert_called_once() + self.k8s_juju_conn.libjuju.get_actions.assert_called_once() + self.k8s_juju_conn.libjuju.get_application_configs.assert_called_once() + + def test_exception(self): + self.k8s_juju_conn.libjuju.get_model.return_value = None + self.k8s_juju_conn.libjuju.get_executed_actions.side_effect = Exception() + with self.assertRaises(Exception): + self.loop.run_until_complete(self.k8s_juju_conn.update_vca_status( + self.vcaStatus, self.kdu_instance)) + self.k8s_juju_conn.libjuju.get_executed_actions.assert_not_called() + self.k8s_juju_conn.libjuju.get_actions.assert_not_called_once() + self.k8s_juju_conn.libjuju.get_application_configs.assert_not_called_once()