This is an automated email from the ASF dual-hosted git repository.
vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new d3764a6758a Add missing unit tests for the common-messaging provider
base class (#72915)
d3764a6758a is described below
commit d3764a6758a0087b96c2a6f43695f9c3588826b4
Author: Keith <[email protected]>
AuthorDate: Fri Sep 11 22:59:03 2026 +0900
Add missing unit tests for the common-messaging provider base class (#72915)
The module was listed in OVERLOOKED_TESTS in test_project_structure.py;
covering the scheme-matching contract shrinks the guard list further
(related: #35442).
---
.../tests/unit/always/test_project_structure.py | 1 -
.../unit/common/messaging/providers/__init__.py | 16 +++++
.../messaging/providers/test_base_provider.py | 71 ++++++++++++++++++++++
3 files changed, 87 insertions(+), 1 deletion(-)
diff --git a/airflow-core/tests/unit/always/test_project_structure.py
b/airflow-core/tests/unit/always/test_project_structure.py
index 5f1fdb140f7..7ac2256b27f 100644
--- a/airflow-core/tests/unit/always/test_project_structure.py
+++ b/airflow-core/tests/unit/always/test_project_structure.py
@@ -97,7 +97,6 @@ class TestProjectStructure:
"providers/common/compat/tests/unit/common/compat/standard/test_operators.py",
"providers/common/compat/tests/unit/common/compat/standard/test_triggers.py",
"providers/common/compat/tests/unit/common/compat/standard/test_utils.py",
-
"providers/common/messaging/tests/unit/common/messaging/providers/test_base_provider.py",
"providers/common/messaging/tests/unit/common/messaging/providers/test_sqs.py",
"providers/edge3/tests/unit/edge3/cli/test_example_extended_sysinfo.py",
"providers/edge3/tests/unit/edge3/models/test_edge_job.py",
diff --git
a/providers/common/messaging/tests/unit/common/messaging/providers/__init__.py
b/providers/common/messaging/tests/unit/common/messaging/providers/__init__.py
new file mode 100644
index 00000000000..13a83393a91
--- /dev/null
+++
b/providers/common/messaging/tests/unit/common/messaging/providers/__init__.py
@@ -0,0 +1,16 @@
+# 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.
diff --git
a/providers/common/messaging/tests/unit/common/messaging/providers/test_base_provider.py
b/providers/common/messaging/tests/unit/common/messaging/providers/test_base_provider.py
new file mode 100644
index 00000000000..df5741da73a
--- /dev/null
+++
b/providers/common/messaging/tests/unit/common/messaging/providers/test_base_provider.py
@@ -0,0 +1,71 @@
+# 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
+
+from airflow.providers.common.messaging.providers.base_provider import
BaseMessageQueueProvider
+
+
+class KafkaLikeProvider(BaseMessageQueueProvider):
+ """Minimal complete provider used to exercise the base-class contract."""
+
+ scheme = "kafka"
+
+ def queue_matches(self, queue: str) -> bool:
+ return queue.startswith("kafka://")
+
+ def trigger_class(self):
+ raise NotImplementedError
+
+ def trigger_kwargs(self, queue: str, **kwargs) -> dict:
+ return {}
+
+
+class TestSchemeMatches:
+ @pytest.mark.parametrize(
+ ("scheme", "expected"),
+ [
+ ("kafka", True),
+ ("sqs", False),
+ ("kafka://", False),
+ ("", False),
+ (None, False),
+ ],
+ )
+ def test_subclass_matches_only_its_own_scheme(self, scheme, expected):
+ assert KafkaLikeProvider().scheme_matches(scheme) is expected
+
+ def test_base_class_scheme_defaults_to_none_and_matches_nothing(self):
+ assert BaseMessageQueueProvider.scheme is None
+ assert KafkaLikeProvider.scheme_matches(BaseMessageQueueProvider(),
"kafka") is False
+
+
[email protected](
+ "method_name",
+ [
+ "queue_matches",
+ "trigger_class",
+ "trigger_kwargs",
+ ],
+)
+def test_provider_contract_methods_are_marked_abstract(method_name):
+ assert getattr(BaseMessageQueueProvider, method_name).__isabstractmethod__
is True
+
+
+def test_scheme_matches_is_part_of_the_concrete_surface():
+ assert getattr(BaseMessageQueueProvider.scheme_matches,
"__isabstractmethod__", False) is False