From 4f13f1b7dbe14033a5ede747c66cbe7e1b933041 Mon Sep 17 00:00:00 2001 From: Andrey Anshin Date: Thu, 9 May 2024 21:12:08 +0400 Subject: [PATCH] Resolve deprecations in `vertica` provider tests (#39519) --- tests/deprecations_ignore.yml | 1 - tests/providers/vertica/operators/test_vertica.py | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/deprecations_ignore.yml b/tests/deprecations_ignore.yml index 21fd16584ca1..5956babd5f2e 100644 --- a/tests/deprecations_ignore.yml +++ b/tests/deprecations_ignore.yml @@ -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 diff --git a/tests/providers/vertica/operators/test_vertica.py b/tests/providers/vertica/operators/test_vertica.py index 8c561add3b78..0668a7304e38 100644 --- a/tests/providers/vertica/operators/test_vertica.py +++ b/tests/providers/vertica/operators/test_vertica.py @@ -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 @@ -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,