This is an automated email from the ASF dual-hosted git repository.
Lee-W 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 b3b62fa8cf3 Add unit tests for common AI provider exceptions (#72082)
b3b62fa8cf3 is described below
commit b3b62fa8cf3c32cb45bb2815385a2af498300754
Author: Sruthi <[email protected]>
AuthorDate: Wed Sep 2 21:53:17 2026 -0700
Add unit tests for common AI provider exceptions (#72082)
Co-authored-by: Cursor <[email protected]>
---
.../tests/unit/always/test_project_structure.py | 1 -
.../ai/tests/unit/common/ai/test_exceptions.py | 55 ++++++++++++++++++++++
2 files changed, 55 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 9aa0a580fcd..bc1bca06407 100644
--- a/airflow-core/tests/unit/always/test_project_structure.py
+++ b/airflow-core/tests/unit/always/test_project_structure.py
@@ -99,7 +99,6 @@ class TestProjectStructure:
"providers/cncf/kubernetes/tests/unit/cncf/kubernetes/utils/test_k8s_hashlib_wrapper.py",
"providers/common/sql/tests/unit/common/sql/datafusion/test_base.py",
"providers/common/sql/tests/unit/common/sql/datafusion/test_exceptions.py",
- "providers/common/ai/tests/unit/common/ai/test_exceptions.py",
"providers/common/compat/tests/unit/common/compat/lineage/test_entities.py",
"providers/common/compat/tests/unit/common/compat/standard/test_operators.py",
"providers/common/compat/tests/unit/common/compat/standard/test_triggers.py",
diff --git a/providers/common/ai/tests/unit/common/ai/test_exceptions.py
b/providers/common/ai/tests/unit/common/ai/test_exceptions.py
new file mode 100644
index 00000000000..b7b95d4cbec
--- /dev/null
+++ b/providers/common/ai/tests/unit/common/ai/test_exceptions.py
@@ -0,0 +1,55 @@
+# 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.ai.exceptions import (
+ HITLMaxIterationsError,
+ LLMFileAnalysisError,
+ LLMFileAnalysisLimitExceededError,
+ LLMFileAnalysisMultimodalRequiredError,
+ LLMFileAnalysisUnsupportedFormatError,
+ ManagedAgentInvocationError,
+)
+from airflow.providers.common.compat.sdk import AirflowException
+
+EXCEPTION_CASES = [
+ (HITLMaxIterationsError, AirflowException),
+ (LLMFileAnalysisError, ValueError),
+ (LLMFileAnalysisUnsupportedFormatError, LLMFileAnalysisError),
+ (LLMFileAnalysisLimitExceededError, LLMFileAnalysisError),
+ (LLMFileAnalysisMultimodalRequiredError,
LLMFileAnalysisUnsupportedFormatError),
+ (ManagedAgentInvocationError, RuntimeError),
+]
+
+
[email protected](("exc_cls", "expected_base"), EXCEPTION_CASES)
+def test_exception_bases_and_message(exc_cls, expected_base):
+ message = "test-message"
+ exc = exc_cls(message)
+
+ assert isinstance(exc, expected_base)
+ assert str(exc) == message
+
+
+def test_llm_file_analysis_exception_chain():
+ exc = LLMFileAnalysisMultimodalRequiredError("need multimodal")
+
+ assert isinstance(exc, LLMFileAnalysisUnsupportedFormatError)
+ assert isinstance(exc, LLMFileAnalysisError)
+ assert isinstance(exc, ValueError)