Feature 10986: Autoheal switch and Autoscale switch
[osm/POL.git] / osm_policy_module / tests / unit / autoscaling / test_autoscaling_service.py
index e5253ea..1588486 100644 (file)
@@ -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,