Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ def _connection_mapper(conn: Connection) -> dict[str, Any]:
def connections_get(args):
"""Get a connection."""
try:
from airflow.sdk import BaseHook

conn = BaseHook.get_connection(args.conn_id)
conn = Connection.get_connection_from_secrets(args.conn_id)
except AirflowNotFoundException:
raise SystemExit("Connection not found.")
AirflowConsole().print_as(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from airflow.cli import cli_config, cli_parser
from airflow.cli.commands import connection_command
from airflow.exceptions import AirflowException, AirflowNotFoundException
from airflow.exceptions import AirflowException
from airflow.models import Connection
from airflow.utils.db import merge_conn
from airflow.utils.session import create_session
Expand Down Expand Up @@ -61,8 +61,7 @@ def test_cli_connection_get(self):
stdout = stdout.getvalue()
assert "google-cloud-platform:///default" in stdout

def test_cli_connection_get_invalid(self, mock_supervisor_comms):
mock_supervisor_comms.send.side_effect = AirflowNotFoundException
def test_cli_connection_get_invalid(self):
with pytest.raises(SystemExit, match=re.escape("Connection not found.")):
connection_command.connections_get(self.parser.parse_args(["connections", "get", "INVALID"]))

Expand Down