Skip to content

Commit

Permalink
Resolve deprecations in vertica provider tests (#39519)
Browse files Browse the repository at this point in the history
  • Loading branch information
Taragolis authored May 9, 2024
1 parent f6098a4 commit 4f13f1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 0 additions & 1 deletion tests/deprecations_ignore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@
- tests/providers/teradata/hooks/test_teradata.py::TestTeradataHook::test_bulk_insert_rows_without_fields
- tests/providers/teradata/hooks/test_teradata.py::TestTeradataHook::test_bulk_insert_rows_no_rows
- tests/providers/trino/operators/test_trino.py::test_execute_openlineage_events
- tests/providers/vertica/operators/test_vertica.py::TestVerticaOperator::test_execute
- tests/providers/weaviate/operators/test_weaviate.py::TestWeaviateIngestOperator::test_constructor
- tests/providers/weaviate/operators/test_weaviate.py::TestWeaviateIngestOperator::test_execute_with_input_json
- tests/providers/yandex/hooks/test_yandex.py::TestYandexHook::test_provider_user_agent
Expand Down
13 changes: 11 additions & 2 deletions tests/providers/vertica/operators/test_vertica.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
# under the License.
from __future__ import annotations

import re
from unittest import mock

import pytest

from airflow.exceptions import AirflowProviderDeprecationWarning
from airflow.providers.common.sql.hooks.sql import fetch_all_handler
from airflow.providers.vertica.operators.vertica import VerticaOperator

Expand All @@ -27,8 +31,13 @@ class TestVerticaOperator:
@mock.patch("airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator.get_db_hook")
def test_execute(self, mock_get_db_hook):
sql = "select a, b, c"
op = VerticaOperator(task_id="test_task_id", sql=sql)
op.execute(None)
warning_message = re.escape(
"Please use `airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator`"
)
with pytest.warns(AirflowProviderDeprecationWarning, match=warning_message):
op = VerticaOperator(task_id="test_task_id", sql=sql)
op.execute({})

mock_get_db_hook.return_value.run.assert_called_once_with(
sql=sql,
autocommit=False,
Expand Down

0 comments on commit 4f13f1b

Please sign in to comment.