Skip to content

Commit

Permalink
Resolve sqlite deprecations in tests (apache#40389)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirrao authored Jun 23, 2024
1 parent 68a87f7 commit fd44198
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 0 additions & 3 deletions tests/deprecations_ignore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,4 @@
- tests/providers/snowflake/operators/test_snowflake.py::TestSnowflakeOperatorForParams::test_overwrite_params
- tests/providers/snowflake/operators/test_snowflake_sql.py::test_exec_success
- tests/providers/snowflake/operators/test_snowflake_sql.py::test_execute_openlineage_events
- tests/providers/sqlite/operators/test_sqlite.py::TestSqliteOperator::test_sqlite_operator_with_invalid_sql
- tests/providers/sqlite/operators/test_sqlite.py::TestSqliteOperator::test_sqlite_operator_with_multiple_statements
- tests/providers/sqlite/operators/test_sqlite.py::TestSqliteOperator::test_sqlite_operator_with_one_statement
- tests/providers/trino/operators/test_trino.py::test_execute_openlineage_events
18 changes: 14 additions & 4 deletions tests/providers/sqlite/operators/test_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import pytest

from airflow.models.dag import DAG
from airflow.providers.sqlite.operators.sqlite import SqliteOperator
from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
from airflow.utils import timezone

DEFAULT_DATE = timezone.datetime(2015, 1, 1)
Expand Down Expand Up @@ -51,15 +51,20 @@ def test_sqlite_operator_with_one_statement(self):
dummy VARCHAR(50)
);
"""
op = SqliteOperator(task_id="basic_sqlite", sql=sql, dag=self.dag)
op = SQLExecuteQueryOperator(task_id="basic_sqlite", sql=sql, dag=self.dag, conn_id="sqlite_default")
op.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True)

def test_sqlite_operator_with_multiple_statements(self):
sql = [
"CREATE TABLE IF NOT EXISTS test_airflow (dummy VARCHAR(50))",
"INSERT INTO test_airflow VALUES ('X')",
]
op = SqliteOperator(task_id="sqlite_operator_with_multiple_statements", sql=sql, dag=self.dag)
op = SQLExecuteQueryOperator(
task_id="sqlite_operator_with_multiple_statements",
sql=sql,
dag=self.dag,
conn_id="sqlite_default",
)
op.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True)

def test_sqlite_operator_with_invalid_sql(self):
Expand All @@ -70,6 +75,11 @@ def test_sqlite_operator_with_invalid_sql(self):

from sqlite3 import OperationalError

op = SqliteOperator(task_id="sqlite_operator_with_multiple_statements", sql=sql, dag=self.dag)
op = SQLExecuteQueryOperator(
task_id="sqlite_operator_with_multiple_statements",
sql=sql,
dag=self.dag,
conn_id="sqlite_default",
)
with pytest.raises(OperationalError, match="no such table: test_airflow2"):
op.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True)

0 comments on commit fd44198

Please sign in to comment.