Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix connection test button #23345

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3847,8 +3847,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
]


Expand Down
13 changes: 12 additions & 1 deletion tests/www/views/test_views_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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