This is an automated email from the ASF dual-hosted git repository.

eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 960b554494 Resolve yandex deprecations in tests (#39929)
960b554494 is described below

commit 960b554494ad782278938f601bdffae353b5740d
Author: Gopal Dirisala <[email protected]>
AuthorDate: Thu May 30 13:05:47 2024 +0530

    Resolve yandex deprecations in tests (#39929)
    
    * Resolve yandex_deprecations in tests
    
    * Resolve yandex deprecations in tests
---
 tests/deprecations_ignore.yml                  |  3 ---
 tests/providers/yandex/hooks/test_yandex.py    | 13 ++++++++++---
 tests/providers/yandex/secrets/test_lockbox.py | 16 ++++++++++++++--
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/tests/deprecations_ignore.yml b/tests/deprecations_ignore.yml
index 8fc84755fd..73e407211a 100644
--- a/tests/deprecations_ignore.yml
+++ b/tests/deprecations_ignore.yml
@@ -685,6 +685,3 @@
 - 
tests/providers/trino/operators/test_trino.py::test_execute_openlineage_events
 - 
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
-- 
tests/providers/yandex/hooks/test_yandex.py::TestYandexHook::test_backcompat_prefix_works
-- 
tests/providers/yandex/secrets/test_lockbox.py::TestLockboxSecretBackend::test_yandex_lockbox_secret_backend_get_connection_from_json
diff --git a/tests/providers/yandex/hooks/test_yandex.py 
b/tests/providers/yandex/hooks/test_yandex.py
index ae6dac568b..da8fe0473b 100644
--- a/tests/providers/yandex/hooks/test_yandex.py
+++ b/tests/providers/yandex/hooks/test_yandex.py
@@ -23,6 +23,7 @@ from unittest.mock import MagicMock
 
 import pytest
 
+from airflow.exceptions import AirflowProviderDeprecationWarning
 from airflow.providers.yandex.hooks.yandex import YandexCloudBaseHook
 from tests.test_utils.config import conf_vars
 
@@ -58,8 +59,11 @@ class TestYandexHook:
         mock_get_credentials.return_value = {"token": 122323}
         sdk_prefix = "MyAirflow"
 
-        with conf_vars({("yandex", "sdk_user_agent_prefix"): sdk_prefix}):
-            hook = YandexCloudBaseHook()
+        hook = YandexCloudBaseHook()
+        with conf_vars({("yandex", "sdk_user_agent_prefix"): sdk_prefix}), 
pytest.warns(
+            AirflowProviderDeprecationWarning,
+            match="Using `provider_user_agent` in `YandexCloudBaseHook` is 
deprecated. Please use it in `utils.user_agent` instead.",
+        ):
             assert hook.provider_user_agent().startswith(sdk_prefix)
 
     @mock.patch("airflow.hooks.base.BaseHook.get_connection")
@@ -84,7 +88,10 @@ class TestYandexHook:
     )
     @mock.patch("airflow.providers.yandex.utils.credentials.get_credentials", 
new=MagicMock())
     def test_backcompat_prefix_works(self, uri):
-        with mock.patch.dict(os.environ, {"AIRFLOW_CONN_MY_CONN": uri}):
+        with mock.patch.dict(os.environ, {"AIRFLOW_CONN_MY_CONN": uri}), 
pytest.warns(
+            AirflowProviderDeprecationWarning,
+            match="Using `connection_id` is deprecated. Please use 
`yandex_conn_id` parameter.",
+        ):
             hook = YandexCloudBaseHook("my_conn")
             assert hook.default_folder_id == "abc"
             assert hook.default_public_ssh_key == "abc"
diff --git a/tests/providers/yandex/secrets/test_lockbox.py 
b/tests/providers/yandex/secrets/test_lockbox.py
index 4cd19c6fb4..451e5a74b4 100644
--- a/tests/providers/yandex/secrets/test_lockbox.py
+++ b/tests/providers/yandex/secrets/test_lockbox.py
@@ -19,10 +19,12 @@ from __future__ import annotations
 import json
 from unittest.mock import MagicMock, Mock, patch
 
+import pytest
 import yandex.cloud.lockbox.v1.payload_pb2 as payload_pb
 import yandex.cloud.lockbox.v1.secret_pb2 as secret_pb
 import yandex.cloud.lockbox.v1.secret_service_pb2 as secret_service_pb
 
+from airflow.exceptions import RemovedInAirflow3Warning
 from airflow.providers.yandex.secrets.lockbox import LockboxSecretBackend
 from airflow.providers.yandex.utils.defaults import default_conn_name
 
@@ -63,11 +65,21 @@ class TestLockboxSecretBackend:
 
         mock_get_value.return_value = json.dumps(c)
 
-        conn = LockboxSecretBackend().get_connection(conn_id)
+        match = "Encountered non-JSON in `extra` field for connection 
'airflow_to_yandexcloud'. Support for non-JSON `extra` will be removed in 
Airflow 3.0"
+        with pytest.warns(
+            RemovedInAirflow3Warning,
+            match=match,
+        ):
+            conn = LockboxSecretBackend().get_connection(conn_id)
+
+        with pytest.warns(
+            RemovedInAirflow3Warning,
+            match=match,
+        ):
+            assert conn.extra == extra
 
         assert conn.conn_id == conn_id
         assert conn.conn_type == conn_type
-        assert conn.extra == extra
 
     
@patch("airflow.providers.yandex.secrets.lockbox.LockboxSecretBackend._get_secret_value")
     def test_yandex_lockbox_secret_backend_get_variable(self, mock_get_value):

Reply via email to