You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ta...@apache.org on 2024/05/09 17:11:27 UTC

(airflow) branch main updated: Resolve deprecations in `apache.livy` provider tests (#39516)

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

taragolis 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 9fa2d6d1a6 Resolve deprecations in `apache.livy` provider tests (#39516)
9fa2d6d1a6 is described below

commit 9fa2d6d1a630478a080581131a2091c9824871b0
Author: Andrey Anshin <An...@taragol.is>
AuthorDate: Thu May 9 21:11:20 2024 +0400

    Resolve deprecations in `apache.livy` provider tests (#39516)
---
 tests/deprecations_ignore.yml                      |  1 -
 tests/providers/apache/livy/operators/test_livy.py | 10 ++++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/tests/deprecations_ignore.yml b/tests/deprecations_ignore.yml
index 6bb385c9d9..36293a6893 100644
--- a/tests/deprecations_ignore.yml
+++ b/tests/deprecations_ignore.yml
@@ -332,7 +332,6 @@
 - tests/providers/amazon/aws/triggers/test_redshift_cluster.py::TestRedshiftClusterTrigger::test_redshift_cluster_sensor_trigger_resuming_status
 - tests/providers/amazon/aws/triggers/test_redshift_cluster.py::TestRedshiftClusterTrigger::test_redshift_cluster_sensor_trigger_success
 - tests/providers/amazon/aws/utils/test_connection_wrapper.py::TestAwsConnectionWrapper::test_get_endpoint_url_from_extra
-- tests/providers/apache/livy/operators/test_livy.py::TestLivyOperator::test_execution_with_extra_options
 - tests/providers/apache/spark/operators/test_spark_sql.py::TestSparkSqlOperator::test_execute
 - tests/providers/atlassian/jira/operators/test_jira.py::TestJiraOperator::test_issue_search
 - tests/providers/atlassian/jira/operators/test_jira.py::TestJiraOperator::test_project_issue_count
diff --git a/tests/providers/apache/livy/operators/test_livy.py b/tests/providers/apache/livy/operators/test_livy.py
index 4e128cbec8..42754c8d2d 100644
--- a/tests/providers/apache/livy/operators/test_livy.py
+++ b/tests/providers/apache/livy/operators/test_livy.py
@@ -21,7 +21,7 @@ from unittest.mock import MagicMock, patch
 
 import pytest
 
-from airflow.exceptions import AirflowException
+from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
 from airflow.models import Connection
 from airflow.models.dag import DAG
 from airflow.providers.apache.livy.hooks.livy import BatchState
@@ -134,7 +134,7 @@ class TestLivyOperator:
 
         task.execute(context=self.mock_context)
 
-        assert task.get_hook().extra_options == extra_options
+        assert task.hook.extra_options == extra_options
 
     @patch("airflow.providers.apache.livy.operators.livy.LivyHook.delete_batch")
     @patch("airflow.providers.apache.livy.operators.livy.LivyHook.post_batch", return_value=BATCH_ID)
@@ -417,6 +417,12 @@ class TestLivyOperator:
         mock_delete.assert_called_once_with(BATCH_ID)
         self.mock_context["ti"].xcom_push.assert_not_called()
 
+    def test_deprecated_get_hook(self):
+        op = LivyOperator(task_id="livy_example", file="sparkapp")
+        with pytest.warns(AirflowProviderDeprecationWarning, match="use `hook` property instead"):
+            hook = op.get_hook()
+        assert hook is op.hook
+
 
 @pytest.mark.db_test
 def test_spark_params_templating(create_task_instance_of_operator):