Skip to content
Closed
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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ repos:
^airflow-ctl.*\.py$|
^airflow-core/src/airflow/models/.*\.py$|
^airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_assets.py$|
^airflow-core/tests/unit/cli/commands/test_connection_command\.py$|
^task_sdk.*\.py$
pass_filenames: true
- id: update-supported-versions
Expand Down
17 changes: 12 additions & 5 deletions airflow-core/tests/unit/cli/commands/test_connection_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from io import StringIO

import pytest
from sqlalchemy import select

from airflow.cli import cli_config, cli_parser
from airflow.cli.commands import connection_command
Expand Down Expand Up @@ -605,7 +606,9 @@ def test_cli_connection_add(self, cmd, expected_output, expected_conn, session,
"schema",
"extra",
]
current_conn = session.query(Connection).filter(Connection.conn_id == conn_id).first()
current_conn = (
session.execute(select(Connection).where(Connection.conn_id == conn_id)).scalars().first()
)
assert expected_conn == {attr: getattr(current_conn, attr) for attr in comparable_attrs}

def test_cli_connections_add_duplicate(self):
Expand Down Expand Up @@ -713,7 +716,7 @@ def test_cli_delete_connections(self, session, stdout_capture):
assert "Successfully deleted connection with `conn_id`=new1" in stdout.getvalue()

# Check deletions
result = session.query(Connection).filter(Connection.conn_id == "new1").first()
result = session.execute(select(Connection).where(Connection.conn_id == "new1")).scalars().first()

assert result is None

Expand Down Expand Up @@ -802,7 +805,11 @@ def test_cli_connections_import_should_load_connections(self, mocker):
expected_imported = {k: v for k, v in expected_connections.items() if k != "new3"}

with create_session() as session:
current_conns = session.query(Connection).filter(Connection.conn_id.in_(["new0", "new1"])).all()
current_conns = (
session.execute(select(Connection).where(Connection.conn_id.in_(["new0", "new1"])))
.scalars()
.all()
)

comparable_attrs = [
"conn_id",
Expand Down Expand Up @@ -871,7 +878,7 @@ def test_cli_connections_import_should_not_overwrite_existing_connections(self,
assert "Could not import connection new3: connection already exists." in mock_print.call_args[0][0]

# Verify that the imported connections match the expected, sample connections
current_conns = session.query(Connection).all()
current_conns = session.execute(select(Connection)).scalars().all()

comparable_attrs = [
"conn_id",
Expand Down Expand Up @@ -942,7 +949,7 @@ def test_cli_connections_import_should_overwrite_existing_connections(self, mock
"Could not import connection new3: connection already exists." not in mock_print.call_args[0][0]
)
# Verify that the imported connections match the expected, sample connections
current_conns = session.query(Connection).all()
current_conns = session.execute(select(Connection)).scalars().all()
comparable_attrs = [
"conn_id",
"conn_type",
Expand Down