kaxil commented on code in PR #72140: URL: https://github.com/apache/airflow/pull/72140#discussion_r3963876279
########## providers/common/compat/tests/unit/common/compat/test_triggers.py: ########## @@ -0,0 +1,36 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from __future__ import annotations + +import pytest + +import airflow.triggers.base +from airflow.providers.common.compat import triggers + + +class TestBaseEventTrigger: + def test_falls_back_to_base_trigger_without_base_event_trigger(self, monkeypatch): + """On Airflow 2.x, where the class does not exist, the alias resolves to BaseTrigger.""" + # Already absent when the tests run against Airflow 2.x, which is the case being simulated. + monkeypatch.delattr(airflow.triggers.base, "BaseEventTrigger", raising=False) + + assert triggers.BaseEventTrigger is airflow.triggers.base.BaseTrigger Review Comment: No test covers the Airflow 3 side, and the fallback makes that gap matter: `create_module_getattr` catches `AttributeError`/`ImportError` from the new path and returns the old name instead, so a typo in the first element of `_RENAME_MAP` would resolve `BaseEventTrigger` to `BaseTrigger` on Airflow 3 with both of these tests still green. `triggerer_job_runner` gates the watcher path on `isinstance(trigger_instance, BaseEventTrigger)`, so an Iceberg watcher would just stop firing. Worth adding an `AIRFLOW_V_3_0_PLUS`-guarded assert that the alias is `airflow.triggers.base.BaseEventTrigger`? -- 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]
