utkarsharma2 commented on code in PR #34592:
URL: https://github.com/apache/airflow/pull/34592#discussion_r1335731016


##########
tests/providers/amazon/aws/sensors/test_batch.py:
##########
@@ -174,6 +201,42 @@ def test_poke_invalid(
         )
         assert "AWS Batch compute environment failed" in str(ctx.value)
 
+    @pytest.mark.parametrize(
+        "soft_fail, expected_exception", ((False, AirflowException), (True, 
AirflowSkipException))
+    )
+    @mock.patch.object(BatchClientHook, "client")
+    def test_fail_poke_no_compute_env(
+        self,
+        mock_batch_client,
+        batch_compute_environment_sensor: BatchComputeEnvironmentSensor,
+        soft_fail,
+        expected_exception,
+    ):
+        compute_env = []
+        mock_batch_client.describe_compute_environments.return_value = 
{"computeEnvironments": compute_env}
+        message = "AWS Batch compute environment"
+        batch_compute_environment_sensor.soft_fail = soft_fail
+        with pytest.raises(expected_exception, match=message):
+            batch_compute_environment_sensor.poke({})
+
+    @pytest.mark.parametrize(
+        "soft_fail, expected_exception", ((False, AirflowException), (True, 
AirflowSkipException))
+    )
+    @mock.patch.object(BatchClientHook, "client")
+    def test_fail_poke_unknown_status(
+        self,
+        mock_batch_client,
+        batch_compute_environment_sensor: BatchComputeEnvironmentSensor,
+        soft_fail,
+        expected_exception,
+    ):
+        compute_env = [{"status": "unknown_status"}]
+        mock_batch_client.describe_compute_environments.return_value = 
{"computeEnvironments": compute_env}
+        message = "AWS Batch compute environment failed. AWS Batch compute 
environment status:"
+        batch_compute_environment_sensor.soft_fail = soft_fail
+        with pytest.raises(expected_exception, match=message):
+            batch_compute_environment_sensor.poke({})

Review Comment:
   It does, we can do this



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to