amoghrajesh commented on code in PR #60218:
URL: https://github.com/apache/airflow/pull/60218#discussion_r2680915931
##########
airflow-core/tests/unit/always/test_providers_manager.py:
##########
@@ -228,61 +128,6 @@ def test_providers_manager_register_dialects(self):
),
)
- def test_hooks(self):
- with warnings.catch_warnings(record=True) as warning_records:
- with self._caplog.at_level(logging.WARNING):
- provider_manager = ProvidersManager()
- connections_list = list(provider_manager.hooks.keys())
- assert len(connections_list) > 60
- if len(self._caplog.records) != 0:
- for record in self._caplog.records:
- print(record.message, file=sys.stderr)
- print(record.exc_info, file=sys.stderr)
- raise AssertionError("There are warnings generated during hook
imports. Please fix them")
- assert [w.message for w in warning_records if "hook-class-names" in
str(w.message)] == []
-
- @skip_if_not_on_main
- @pytest.mark.execution_timeout(150)
- def test_hook_values(self):
- provider_dependencies = json.loads(
- (AIRFLOW_ROOT_PATH / "generated" /
"provider_dependencies.json").read_text()
- )
- python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
- excluded_providers: list[str] = []
- for provider_name, provider_info in provider_dependencies.items():
- if python_version in provider_info.get("excluded-python-versions",
[]):
-
excluded_providers.append(f"apache-airflow-providers-{provider_name.replace('.',
'-')}")
- with warnings.catch_warnings(record=True) as warning_records:
- with self._caplog.at_level(logging.WARNING):
- provider_manager = ProvidersManager()
- connections_list = list(provider_manager.hooks.values())
- assert len(connections_list) > 60
- if len(self._caplog.records) != 0:
- real_warning_count = 0
- for record in self._caplog.entries:
- # When there is error importing provider that is excluded the
provider name is in the message
- if any(excluded_provider in record["event"] for
excluded_provider in excluded_providers):
- continue
- print(record["event"], file=sys.stderr)
- print(record.get("exc_info"), file=sys.stderr)
- real_warning_count += 1
- if real_warning_count:
- if PY313:
- only_ydb_and_yandexcloud_warnings = True
- for record in warning_records:
- if "ydb" in str(record.message) or "yandexcloud" in
str(record.message):
- continue
- only_ydb_and_yandexcloud_warnings = False
- if only_ydb_and_yandexcloud_warnings:
- print(
- "Only warnings from ydb and yandexcloud providers
are generated, "
- "which is expected in Python 3.13+",
- file=sys.stderr,
- )
- return
- raise AssertionError("There are warnings generated during hook
imports. Please fix them")
- assert [w.message for w in warning_records if "hook-class-names" in
str(w.message)] == []
Review Comment:
Same as above
##########
airflow-core/tests/unit/always/test_providers_manager.py:
##########
@@ -375,34 +220,6 @@ def test_dialects(self):
assert len(dialect_class_names) == 3
assert dialect_class_names == ["default", "mssql", "postgresql"]
- @patch("airflow.providers_manager.import_string")
- def test_optional_feature_no_warning(self, mock_importlib_import_string):
- with self._caplog.at_level(logging.WARNING):
- mock_importlib_import_string.side_effect =
AirflowOptionalProviderFeatureException()
- providers_manager = ProvidersManager()
- providers_manager._hook_provider_dict["test_connection"] =
HookClassProvider(
- package_name="test_package", hook_class_name="HookClass"
- )
- providers_manager._import_hook(
- hook_class_name=None, provider_info=None, package_name=None,
connection_type="test_connection"
- )
- assert self._caplog.messages == []
-
- @patch("airflow.providers_manager.import_string")
- def test_optional_feature_debug(self, mock_importlib_import_string):
- with self._caplog.at_level(logging.INFO):
- mock_importlib_import_string.side_effect =
AirflowOptionalProviderFeatureException()
- providers_manager = ProvidersManager()
- providers_manager._hook_provider_dict["test_connection"] =
HookClassProvider(
- package_name="test_package", hook_class_name="HookClass"
- )
- providers_manager._import_hook(
- hook_class_name=None, provider_info=None, package_name=None,
connection_type="test_connection"
- )
- assert self._caplog.messages == [
- "Optional provider feature disabled when importing 'HookClass'
from 'test_package' package"
- ]
Review Comment:
Same as above
--
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]