Skip to content

Commit 77eac18

Browse files
committed
Add tests
1 parent 92aefa3 commit 77eac18

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/amazon/aws/sensors/test_s3_sensors.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from unittest import mock
55

66
import pytest
7-
from airflow.exceptions import AirflowException, TaskDeferred
7+
from airflow.exceptions import AirflowException, AirflowSkipException, TaskDeferred
88
from airflow.models import DAG, DagRun, TaskInstance
99
from airflow.models.variable import Variable
1010
from airflow.utils import timezone
@@ -245,6 +245,16 @@ def test_s3_key_sensor_with_wildcard_async(self, mock_hook, mock_poke, context):
245245

246246
assert isinstance(exc.value.trigger, S3KeyTrigger), "Trigger is not a S3KeyTrigger"
247247

248+
def test_soft_fail(self):
249+
"""Raise AirflowSkipException in case soft_fail is true"""
250+
sensor = S3KeySensorAsync(
251+
task_id="s3_key_sensor_async", bucket_key="key", bucket_name="bucket", soft_fail=True
252+
)
253+
with pytest.raises(AirflowSkipException):
254+
sensor.execute_complete(
255+
context={}, event={"status": "error", "message": "mocked error", "soft_fail": True}
256+
)
257+
248258

249259
class TestS3KeysUnchangedSensorAsync:
250260
@mock.patch(f"{MODULE}.S3KeysUnchangedSensorAsync.defer")

0 commit comments

Comments
 (0)