Skip to content

Commit

Permalink
Retain session.query in test
Browse files Browse the repository at this point in the history
  • Loading branch information
phanikumv committed Jul 7, 2023
1 parent 79efd74 commit 66d79eb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/cli/commands/test_connection_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from unittest import mock

import pytest
from sqlalchemy import select

from airflow.cli import cli_parser
from airflow.cli.commands import connection_command
Expand Down Expand Up @@ -565,7 +564,7 @@ def test_cli_connection_add(self, cmd, expected_output, expected_conn):
"port",
"schema",
]
current_conn = session.scalars(select(Connection).where(Connection.conn_id == conn_id)).first()
current_conn = session.query(Connection).filter(Connection.conn_id == conn_id).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 @@ -675,7 +674,7 @@ def test_cli_delete_connections(self, session=None):
assert "Successfully deleted connection with `conn_id`=new1" in stdout

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

assert result is None

Expand Down Expand Up @@ -751,7 +750,7 @@ def test_cli_connections_import_should_load_connections(self, mock_exists, mock_

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

comparable_attrs = [
"conn_id",
Expand Down Expand Up @@ -828,7 +827,7 @@ def test_cli_connections_import_should_not_overwrite_existing_connections(
assert "Could not import connection new3: connection already exists." in stdout.getvalue()

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

comparable_attrs = [
"conn_id",
Expand Down Expand Up @@ -908,7 +907,7 @@ def test_cli_connections_import_should_overwrite_existing_connections(
assert "Could not import connection new3: connection already exists." not in stdout.getvalue()

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

comparable_attrs = [
"conn_id",
Expand Down

0 comments on commit 66d79eb

Please sign in to comment.