Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def poke(self, context: Context) -> bool:

if state in self.INTERMEDIATE_STATES:
return False
return True
return state in self.SUCCESS_STATES

def execute(self, context: Context):
if not self.deferrable:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ def test_poke_cancel_pending(self, mock_check_query_status):
assert "EMR Containers sensor failed" in str(ctx.value)
assert "CANCEL_PENDING" in str(ctx.value)

@mock.patch.object(EmrContainerHook, "check_query_status", side_effect=(None,))
def test_poke_unknown_state(self, mock_check_query_status):
"""An unknown state must not be reported as a successful job run.

``EmrContainerHook.check_query_status`` swallows a generic ``ClientError``
and returns ``None``, which ``poll_query_status`` passes straight through
once ``max_polling_attempts`` is reached.
"""
assert not self.sensor.poke(None)

@mock.patch.object(EmrContainerHook, "check_query_status", side_effect=("SOME_FUTURE_STATE",))
def test_poke_unrecognised_state(self, mock_check_query_status):
"""A state added by AWS later must not be reported as a successful job run."""
assert not self.sensor.poke(None)

@mock.patch("airflow.providers.amazon.aws.sensors.emr.EmrContainerSensor.poke")
def test_sensor_defer(self, mock_poke):
self.sensor.deferrable = True
Expand Down