diff --git a/airflow/www/views.py b/airflow/www/views.py index f73b8107b957c..9bdd761022cd2 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -3867,8 +3867,8 @@ def field_behaviours(self): def testable_connection_types(self): return [ connection_type - for connection_type, provider_info in ProvidersManager().hooks.items() - if provider_info.connection_testable + for connection_type, hook_info in ProvidersManager().hooks.items() + if hook_info and hook_info.connection_testable ] diff --git a/tests/www/views/test_views_connection.py b/tests/www/views/test_views_connection.py index 8c5ff0d013c06..d71a8a63c0c82 100644 --- a/tests/www/views/test_views_connection.py +++ b/tests/www/views/test_views_connection.py @@ -25,7 +25,7 @@ from airflow.models import Connection from airflow.utils.session import create_session from airflow.www.extensions import init_views -from airflow.www.views import ConnectionModelView +from airflow.www.views import ConnectionFormWidget, ConnectionModelView from tests.test_utils.www import check_content_in_response CONNECTION = { @@ -311,3 +311,14 @@ def test_connection_muldelete(admin_client, connection): assert resp.status_code == 200 with create_session() as session: assert session.query(Connection).filter(Connection.id == conn_id).count() == 0 + + +@mock.patch('airflow.providers_manager.ProvidersManager.hooks', new_callable=PropertyMock) +def test_connection_form_widgets_testable_types(mock_pm_hooks, admin_client): + mock_pm_hooks.return_value = { + "first": mock.MagicMock(connection_testable=True), + "second": mock.MagicMock(connection_testable=False), + "third": None, + } + + assert ["first"] == ConnectionFormWidget().testable_connection_types