Skip to content
Open
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
1 change: 0 additions & 1 deletion generated/known_airflow_exceptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ providers/amazon/src/airflow/providers/amazon/aws/sensors/sagemaker.py::8
providers/amazon/src/airflow/providers/amazon/aws/sensors/sagemaker_unified_studio.py::1
providers/amazon/src/airflow/providers/amazon/aws/sensors/sqs.py::2
providers/amazon/src/airflow/providers/amazon/aws/sensors/step_function.py::1
providers/amazon/src/airflow/providers/amazon/aws/transfers/gcs_to_s3.py::1
providers/amazon/src/airflow/providers/amazon/aws/transfers/redshift_to_s3.py::1
providers/amazon/src/airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py::3
providers/amazon/src/airflow/providers/amazon/aws/transfers/s3_to_redshift.py::3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from packaging.version import Version

from airflow.providers.amazon.aws.hooks.s3 import S3Hook
from airflow.providers.common.compat.sdk import AirflowException, BaseOperator
from airflow.providers.common.compat.sdk import BaseOperator
from airflow.providers.google.cloud.hooks.gcs import GCSHook

if TYPE_CHECKING:
Expand Down Expand Up @@ -146,10 +146,8 @@ def __init__(
self.__is_match_glob_supported = False
except ImportError: # __version__ was added in 10.1.0, so this means it's < 10.3.0
self.__is_match_glob_supported = False
if not self.__is_match_glob_supported and match_glob:
raise AirflowException(
"The 'match_glob' parameter requires 'apache-airflow-providers-google>=10.3.0'."
)
if not self.__is_match_glob_supported and match_glob is not None:
raise ValueError("The 'match_glob' parameter requires 'apache-airflow-providers-google>=10.3.0'.")
self.match_glob = match_glob
self.gcp_user_project = gcp_user_project

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ def test_execute__match_glob(self, mock_hook):
user_project=None,
)

@mock.patch("airflow.providers.google.__version__", "10.2.0")
@pytest.mark.parametrize("match_glob", [f"**/*{DELIMITER}", ""])
def test_match_glob_requires_recent_google_provider(self, match_glob):
with pytest.raises(ValueError, match="match_glob"):
GCSToS3Operator(
task_id=TASK_ID,
gcs_bucket=GCS_BUCKET,
prefix=PREFIX,
dest_aws_conn_id="aws_default",
dest_s3_key=S3_BUCKET,
match_glob=match_glob,
)
Comment on lines +78 to +89

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test passes match_glob=f"**/*{DELIMITER}", which is truthy, so it would still pass against the old if not ... and match_glob: condition — the only thing failing it on main is the AirflowExceptionValueError swap, not the polarity change. Since is not None vs. truthiness was the substance of the review round, worth parametrising so the empty-string case is pinned:

Suggested change
@mock.patch("airflow.providers.google.__version__", "10.2.0")
def test_match_glob_requires_recent_google_provider(self):
with pytest.raises(ValueError, match="match_glob"):
GCSToS3Operator(
task_id=TASK_ID,
gcs_bucket=GCS_BUCKET,
prefix=PREFIX,
dest_aws_conn_id="aws_default",
dest_s3_key=S3_BUCKET,
match_glob=f"**/*{DELIMITER}",
)
@mock.patch("airflow.providers.google.__version__", "10.2.0")
@pytest.mark.parametrize("match_glob", [f"**/*{DELIMITER}", ""])
def test_match_glob_requires_recent_google_provider(self, match_glob):
with pytest.raises(ValueError, match="match_glob"):
GCSToS3Operator(
task_id=TASK_ID,
gcs_bucket=GCS_BUCKET,
prefix=PREFIX,
dest_aws_conn_id="aws_default",
dest_s3_key=S3_BUCKET,
match_glob=match_glob,
)

AGENTS.md asks for @pytest.mark.parametrize when tests differ only in input, so this stays one test rather than two.


@mock.patch("airflow.providers.amazon.aws.transfers.gcs_to_s3.GCSHook")
def test_execute_incremental(self, mock_hook):
mock_hook.return_value.list.return_value = MOCK_FILES
Expand Down
1 change: 0 additions & 1 deletion scripts/ci/prek/validate_operators_init_exemptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# Burn-down tracked at https://github.com/apache/airflow/issues/70296
providers/amazon/src/airflow/providers/amazon/aws/operators/neptune.py::NeptuneStartDbClusterOperator
providers/amazon/src/airflow/providers/amazon/aws/operators/neptune.py::NeptuneStopDbClusterOperator
providers/amazon/src/airflow/providers/amazon/aws/transfers/gcs_to_s3.py::GCSToS3Operator
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py::KubernetesPodOperator
providers/google/src/airflow/providers/google/cloud/operators/cloud_batch.py::CloudBatchSubmitJobOperator
providers/google/src/airflow/providers/google/cloud/operators/cloud_build.py::CloudBuildCreateBuildOperator
Expand Down