Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Async GCSObjectsWithPrefixExistenceSensor xcom push #37634

Merged
merged 1 commit into from Feb 22, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions airflow/providers/google/cloud/sensors/gcs.py
Expand Up @@ -363,6 +363,8 @@ def execute(self, context: Context):
),
method_name="execute_complete",
)
else:
return self._matches

def execute_complete(self, context: dict[str, Any], event: dict[str, str | list[str]]) -> str | list[str]:
"""Return immediately and rely on trigger to throw a success event. Callback for the trigger."""
Expand Down
14 changes: 14 additions & 0 deletions tests/providers/google/cloud/sensors/test_gcs.py
Expand Up @@ -429,6 +429,20 @@ def test_gcs_object_prefix_existence_sensor_finish_before_deferred(self, mock_de
task.execute(mock.MagicMock())
assert not mock_defer.called

@mock.patch("airflow.providers.google.cloud.sensors.gcs.GCSHook")
def test_xcom_value_when_poke_success(self, mock_hook):
mock_hook.return_value.list.return_value = ["test.txt"]
task = GCSObjectsWithPrefixExistenceSensor(
task_id="task-id",
bucket=TEST_BUCKET,
prefix=TEST_PREFIX,
google_cloud_conn_id=TEST_GCP_CONN_ID,
impersonation_chain=TEST_IMPERSONATION_CHAIN,
deferrable=True,
)
responses = task.execute(None)
assert responses == ["test.txt"]


class TestGCSObjectsWithPrefixExistenceAsyncSensor:
OPERATOR = GCSObjectsWithPrefixExistenceSensor(
Expand Down