shahar1 commented on code in PR #39929:
URL: https://github.com/apache/airflow/pull/39929#discussion_r1619953811


##########
tests/providers/yandex/secrets/test_lockbox.py:
##########
@@ -63,11 +65,15 @@ def 
test_yandex_lockbox_secret_backend_get_connection_from_json(self, mock_get_v
 
         mock_get_value.return_value = json.dumps(c)
 
-        conn = LockboxSecretBackend().get_connection(conn_id)
+        with pytest.warns(
+            RemovedInAirflow3Warning,
+            match="Encountered non-JSON in `extra` field for connection 
'airflow_to_yandexcloud'. Support for non-JSON `extra` will be removed in 
Airflow 3.0",
+        ):
+            conn = LockboxSecretBackend().get_connection(conn_id)
 
-        assert conn.conn_id == conn_id
-        assert conn.conn_type == conn_type
-        assert conn.extra == extra
+            assert conn.conn_id == conn_id
+            assert conn.conn_type == conn_type
+            assert conn.extra == extra

Review Comment:
   I'd probably change to something like this to isolate the causes of the 
warning:
   ```python
           match = "Encountered non-JSON in `extra` field for connection 
'airflow_to_yandexcloud'."
           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
   ```



##########
tests/providers/yandex/hooks/test_yandex.py:
##########
@@ -58,7 +59,10 @@ def test_provider_user_agent(self, mock_get_credentials, 
mock_get_connection):
         mock_get_credentials.return_value = {"token": 122323}
         sdk_prefix = "MyAirflow"
 
-        with conf_vars({("yandex", "sdk_user_agent_prefix"): sdk_prefix}):
+        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.",
+        ):
             hook = YandexCloudBaseHook()

Review Comment:
   It's better to move the hook init. out of the context manager:
   ```suggestion
           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.",
           ):
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to