X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_policy_module%2Ftests%2Funit%2Fcore%2Ftest_policy_agent.py;h=7aab92885761075d5fc7bdec4b4f892eb4f2f21c;hb=055c4ee00f83647e7e807aa3d44c3384d9d79aa2;hp=cc178916e5586607b0a141658b0dcd266fd98212;hpb=7ef2b88a9c0c6ead16861411584d017e1fe216d7;p=osm%2FPOL.git diff --git a/osm_policy_module/tests/unit/core/test_policy_agent.py b/osm_policy_module/tests/unit/core/test_policy_agent.py index cc17891..7aab928 100644 --- a/osm_policy_module/tests/unit/core/test_policy_agent.py +++ b/osm_policy_module/tests/unit/core/test_policy_agent.py @@ -76,7 +76,7 @@ class PolicyAgentTest(unittest.TestCase): pass config = Config() - agent = PolicyModuleAgent(config, self.loop) + agent = PolicyModuleAgent(config) assert autoscaling_lcm_client.called assert autoscaling_mon_client.called assert alarming_lcm_client.called @@ -110,16 +110,24 @@ class PolicyAgentTest(unittest.TestCase): @mock.patch("osm_policy_module.alarming.service.LcmClient") @mock.patch("osm_policy_module.autoscaling.service.MonClient") @mock.patch("osm_policy_module.autoscaling.service.LcmClient") + @mock.patch("osm_policy_module.healing.service.MonClient") + @mock.patch("osm_policy_module.healing.service.LcmClient") + @mock.patch.object(HealingService, "configure_healing_alarms") @mock.patch.object(AutoscalingService, "configure_scaling_groups") @mock.patch.object(AlarmingService, "configure_vnf_alarms") + @mock.patch.object(HealingService, "delete_healing_alarms") @mock.patch.object(AutoscalingService, "delete_scaling_groups") @mock.patch.object(AlarmingService, "delete_vnf_alarms") def test_handle_policy_update( self, delete_vnf_alarms, delete_scaling_groups, + delete_healing_alarms, configure_vnf_alarms, configure_scaling_groups, + configure_healing_alarms, + healing_lcm_client, + healing_mon_client, autoscaling_lcm_client, autoscaling_mon_client, alarming_lcm_client, @@ -131,32 +139,42 @@ class PolicyAgentTest(unittest.TestCase): async def mock_delete_vnf_alarms(nsr_id, vnf_member_index): pass + async def mock_delete_healing_alarms(nsr_id, vnf_member_index): + pass + async def mock_configure_scaling_groups(nsr_id, vnf_member_index): pass async def mock_configure_vnf_alarms(nsr_id, vnf_member_index): pass + async def mock_configure_healing_alarms(nsr_id, vnf_member_index): + pass + config = Config() - agent = PolicyModuleAgent(config, self.loop) + agent = PolicyModuleAgent(config) assert autoscaling_lcm_client.called assert autoscaling_mon_client.called assert alarming_lcm_client.called assert alarming_mon_client.called + assert healing_lcm_client.called + assert healing_mon_client.called content = { "nsr_id": "test_nsr_id", "vnf_member_index": "1", - "operationState": "COMPLETED" + "operationState": "COMPLETED", } failed_content = { "nsr_id": "test_nsr_id", "vnf_member_index": "1", - "operationState": "FAILED" + "operationState": "FAILED", } configure_scaling_groups.side_effect = mock_configure_scaling_groups configure_vnf_alarms.side_effect = mock_configure_vnf_alarms + configure_healing_alarms.side_effect = mock_configure_healing_alarms delete_scaling_groups.side_effect = mock_delete_scaling_groups delete_vnf_alarms.side_effect = mock_delete_vnf_alarms + delete_healing_alarms.side_effect = mock_delete_healing_alarms self.loop.run_until_complete(agent._handle_policy_update(content)) configure_scaling_groups.assert_called_with("test_nsr_id", "1") @@ -191,7 +209,7 @@ class PolicyAgentTest(unittest.TestCase): pass config = Config() - agent = PolicyModuleAgent(config, self.loop) + agent = PolicyModuleAgent(config) assert autoscaling_lcm_client.called assert autoscaling_mon_client.called assert alarming_lcm_client.called @@ -242,7 +260,7 @@ class PolicyAgentTest(unittest.TestCase): pass config = Config() - agent = PolicyModuleAgent(config, self.loop) + agent = PolicyModuleAgent(config) assert autoscaling_lcm_client.called assert autoscaling_mon_client.called assert alarming_lcm_client.called @@ -250,12 +268,12 @@ class PolicyAgentTest(unittest.TestCase): content = { "nsr_id": "test_nsr_id", "vnf_member_index": "1", - "operationState": "COMPLETED" + "operationState": "COMPLETED", } failed_content = { "nsr_id": "test_nsr_id", "vnf_member_index": "1", - "operationState": "FAILED" + "operationState": "FAILED", } delete_scaling_groups.side_effect = mock_delete_scaling_groups delete_vnf_alarms.side_effect = mock_delete_vnf_alarms