This is an automated email from the ASF dual-hosted git repository.
shahar1 pushed a commit to branch airflow-ctl/v0-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/airflow-ctl/v0-1-test by this
push:
new 80880e4e5dc [airflow-ctl/v0-1-test] Add tests for airflowctl utils
helpers and module loading (#76271) (#76379)
80880e4e5dc is described below
commit 80880e4e5dcdfa065104415ed0a6e22a1a646699
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Nov 3 16:04:16 2026 +0000
[airflow-ctl/v0-1-test] Add tests for airflowctl utils helpers and module
loading (#76271) (#76379)
(cherry picked from commit ff22d7313cad812ad2c5021c9fb5ed9a3871b0bd)
Co-authored-by: ZJ-lucky-0915 <[email protected]>
---
airflow-ctl/tests/airflow_ctl/utils/__init__.py | 16 ++++++++
.../tests/airflow_ctl/utils/test_helpers.py | 45 ++++++++++++++++++++++
.../tests/airflow_ctl/utils/test_module_loading.py | 43 +++++++++++++++++++++
3 files changed, 104 insertions(+)
diff --git a/airflow-ctl/tests/airflow_ctl/utils/__init__.py
b/airflow-ctl/tests/airflow_ctl/utils/__init__.py
new file mode 100644
index 00000000000..13a83393a91
--- /dev/null
+++ b/airflow-ctl/tests/airflow_ctl/utils/__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/airflow-ctl/tests/airflow_ctl/utils/test_helpers.py
b/airflow-ctl/tests/airflow_ctl/utils/test_helpers.py
new file mode 100644
index 00000000000..026e8d623c1
--- /dev/null
+++ b/airflow-ctl/tests/airflow_ctl/utils/test_helpers.py
@@ -0,0 +1,45 @@
+# 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
+
+from airflowctl.utils.helpers import partition
+
+
+def test_partition_splits_false_and_true_entries():
+ false_entries, true_entries = partition(lambda value: value % 2 == 0, [0,
1, 2, 3, 4])
+
+ assert list(false_entries) == [1, 3]
+ assert list(true_entries) == [0, 2, 4]
+
+
+def test_partition_handles_empty_iterable():
+ false_entries, true_entries = partition(bool, [])
+
+ assert list(false_entries) == []
+ assert list(true_entries) == []
+
+
+def test_partition_works_with_one_shot_iterators():
+ source = (value for value in range(4))
+
+ false_entries, true_entries = partition(lambda value: value >= 2, source)
+
+ # Consume the true group first; tee must still let both sides see the full
input.
+ assert list(true_entries) == [2, 3]
+ assert list(false_entries) == [0, 1]
diff --git a/airflow-ctl/tests/airflow_ctl/utils/test_module_loading.py
b/airflow-ctl/tests/airflow_ctl/utils/test_module_loading.py
new file mode 100644
index 00000000000..101465b18a9
--- /dev/null
+++ b/airflow-ctl/tests/airflow_ctl/utils/test_module_loading.py
@@ -0,0 +1,43 @@
+# 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 airflowctl.utils.helpers import partition
+from airflowctl.utils.module_loading import import_string
+
+
+def test_import_string_returns_attribute():
+ assert import_string("airflowctl.utils.helpers.partition") is partition
+
+
+def test_import_string_rejects_path_without_dot():
+ with pytest.raises(ImportError, match="doesn't look like a module path"):
+ import_string("not_a_module")
+
+
+def test_import_string_propagates_missing_module():
+ with pytest.raises(ModuleNotFoundError):
+ import_string("definitely_not_a_module.attribute")
+
+
+def test_import_string_reports_missing_attribute():
+ with pytest.raises(ImportError, match='does not define a "missing"
attribute/class'):
+ import_string("airflowctl.utils.helpers.missing")