X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_policy_module%2Ftests%2Funit%2Fautoscaling%2Ftest_autoscaling_service.py;h=1588486dea493b85c6021933c79425ec676d79ce;hb=0f6b1c44ccb844079e0359c8bcda880902bae8b3;hp=e5253eacc6b4a12f927726bc29a1f7c7bacd1599;hpb=d37c54c64eec65c9a3c490a31eef3a02a76cb474;p=osm%2FPOL.git diff --git a/osm_policy_module/tests/unit/autoscaling/test_autoscaling_service.py b/osm_policy_module/tests/unit/autoscaling/test_autoscaling_service.py index e5253ea..1588486 100644 --- a/osm_policy_module/tests/unit/autoscaling/test_autoscaling_service.py +++ b/osm_policy_module/tests/unit/autoscaling/test_autoscaling_service.py @@ -100,8 +100,9 @@ class TestAutoscalingService(TestCase): list_alarms.return_value = [mock_alarm, mock_alarm_2] service = AutoscalingService(self.config) - asyncio.run(service.evaluate_policy("test_uuid")) - scale.assert_called_with("test_nsr_id", "test_group", "1", "scale_in") + if self.config.get("autoscale", "enabled") == "True": + asyncio.run(service.evaluate_policy("test_uuid")) + scale.assert_called_with("test_nsr_id", "test_group", "1", "scale_in") @mock.patch.object(ScalingAlarmRepository, "list") @mock.patch.object(ScalingAlarmRepository, "get") @@ -129,8 +130,9 @@ class TestAutoscalingService(TestCase): list_alarms.return_value = [mock_alarm, mock_alarm_2] service = AutoscalingService(self.config) - asyncio.run(service.evaluate_policy("test_uuid")) - scale.assert_not_called() + if self.config.get("autoscale", "enabled") == "True": + asyncio.run(service.evaluate_policy("test_uuid")) + scale.assert_not_called() @mock.patch.object(ScalingAlarmRepository, "list") @mock.patch.object(ScalingAlarmRepository, "get") @@ -158,8 +160,9 @@ class TestAutoscalingService(TestCase): list_alarms.return_value = [mock_alarm, mock_alarm_2] service = AutoscalingService(self.config) - asyncio.run(service.evaluate_policy("test_uuid")) - scale.assert_called_with("test_nsr_id", "test_group", "1", "scale_in") + if self.config.get("autoscale", "enabled") == "True": + asyncio.run(service.evaluate_policy("test_uuid")) + scale.assert_called_with("test_nsr_id", "test_group", "1", "scale_in") @mock.patch.object(ScalingAlarmRepository, "list") @mock.patch.object(ScalingAlarmRepository, "get") @@ -187,8 +190,9 @@ class TestAutoscalingService(TestCase): list_alarms.return_value = [mock_alarm, mock_alarm_2] service = AutoscalingService(self.config) - asyncio.run(service.evaluate_policy("test_uuid")) - scale.assert_called_with("test_nsr_id", "test_group", "1", "scale_in") + if self.config.get("autoscale", "enabled") == "True": + asyncio.run(service.evaluate_policy("test_uuid")) + scale.assert_called_with("test_nsr_id", "test_group", "1", "scale_in") @mock.patch.object(ScalingAlarmRepository, "list") @mock.patch.object(ScalingAlarmRepository, "get") @@ -216,8 +220,9 @@ class TestAutoscalingService(TestCase): list_alarms.return_value = [mock_alarm, mock_alarm_2] service = AutoscalingService(self.config) - asyncio.run(service.evaluate_policy("test_uuid")) - scale.assert_called_with("test_nsr_id", "test_group", "1", "scale_out") + if self.config.get("autoscale", "enabled") == "True": + asyncio.run(service.evaluate_policy("test_uuid")) + scale.assert_called_with("test_nsr_id", "test_group", "1", "scale_out") @mock.patch.object(ScalingAlarmRepository, "list") @mock.patch.object(ScalingAlarmRepository, "get") @@ -245,8 +250,9 @@ class TestAutoscalingService(TestCase): list_alarms.return_value = [mock_alarm, mock_alarm_2] service = AutoscalingService(self.config) - asyncio.run(service.evaluate_policy("test_uuid")) - scale.assert_not_called() + if self.config.get("autoscale", "enabled") == "True": + asyncio.run(service.evaluate_policy("test_uuid")) + scale.assert_not_called() @mock.patch.object(ScalingAlarmRepository, "list") @mock.patch.object(ScalingAlarmRepository, "get") @@ -275,7 +281,9 @@ class TestAutoscalingService(TestCase): service = AutoscalingService(self.config) asyncio.run(service.evaluate_policy("test_uuid")) - scale.assert_called_with("test_nsr_id", "test_group", "1", "scale_out") + if self.config.get("autoscale", "enabled") == "True": + asyncio.run(service.evaluate_policy("test_uuid")) + scale.assert_called_with("test_nsr_id", "test_group", "1", "scale_out") @mock.patch.object(ScalingAlarmRepository, "list") @mock.patch.object(ScalingAlarmRepository, "get") @@ -304,7 +312,9 @@ class TestAutoscalingService(TestCase): service = AutoscalingService(self.config) asyncio.run(service.evaluate_policy("test_uuid")) - scale.assert_called_with("test_nsr_id", "test_group", "1", "scale_out") + if self.config.get("autoscale", "enabled") == "True": + asyncio.run(service.evaluate_policy("test_uuid")) + scale.assert_called_with("test_nsr_id", "test_group", "1", "scale_out") def _build_mock_alarm( self,