Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve deprecations in apache.livy provider tests #39516

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/deprecations_ignore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,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
Expand Down
10 changes: 8 additions & 2 deletions tests/providers/apache/livy/operators/test_livy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

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
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_execution_with_extra_options(self, mock_get_batch, mock_post):

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)
Expand Down Expand Up @@ -417,6 +417,12 @@ def test_execute_complete_timeout(self, mock_delete, mock_post):
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):
Expand Down