From 9b67a5ea333615797d2c71d28a4ec52871f412b6 Mon Sep 17 00:00:00 2001 From: Gopal Dirisala <39794726+dirrao@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:52:49 +0530 Subject: [PATCH] Resolve trigger dagrun operator deprecations in tests (#40003) * Resolve trigger dagrun operator deprecations in tests * Fix import order --------- Co-authored-by: Tzu-ping Chung --- tests/deprecations_ignore.yml | 16 ---------------- tests/operators/test_trigger_dagrun.py | 18 +++++++++++------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/tests/deprecations_ignore.yml b/tests/deprecations_ignore.yml index 541d89898ff64..286215d45bae9 100644 --- a/tests/deprecations_ignore.yml +++ b/tests/deprecations_ignore.yml @@ -116,22 +116,6 @@ - tests/operators/test_subdag_operator.py::TestSubDagOperator::test_subdag_pools - tests/operators/test_subdag_operator.py::TestSubDagOperator::test_subdag_pools_no_possible_conflict - tests/operators/test_subdag_operator.py::TestSubDagOperator::test_subdag_with_propagate_skipped_state -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_custom_run_id -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_operator_conf -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_operator_templated_conf -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_twice -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_with_execution_date -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_with_reset_dag_run_false -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_with_reset_dag_run_false_fail -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_with_reset_dag_run_true -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_with_scheduled_dag_run -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_with_templated_execution_date -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_with_wait_for_completion_true -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_with_wait_for_completion_true_defer_false -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_with_wait_for_completion_true_defer_true -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_with_wait_for_completion_true_defer_true_failure -- tests/operators/test_trigger_dagrun.py::TestDagRunOperator::test_trigger_dagrun_with_wait_for_completion_true_defer_true_failure_2 # Serialization diff --git a/tests/operators/test_trigger_dagrun.py b/tests/operators/test_trigger_dagrun.py index 55c3e89e7e7ea..7bee42243b50d 100644 --- a/tests/operators/test_trigger_dagrun.py +++ b/tests/operators/test_trigger_dagrun.py @@ -25,7 +25,7 @@ import pendulum import pytest -from airflow.exceptions import AirflowException, DagRunAlreadyExists, TaskDeferred +from airflow.exceptions import AirflowException, DagRunAlreadyExists, RemovedInAirflow3Warning, TaskDeferred from airflow.models.dag import DAG, DagModel from airflow.models.dagbag import DagBag from airflow.models.dagrun import DagRun @@ -551,12 +551,16 @@ def test_trigger_dagrun_with_wait_for_completion_true_defer_true_failure_2(self) def test_trigger_dagrun_with_execution_date(self): """Test TriggerDagRunOperator with custom execution_date (deprecated parameter)""" custom_execution_date = timezone.datetime(2021, 1, 2, 3, 4, 5) - task = TriggerDagRunOperator( - task_id="test_trigger_dagrun_with_execution_date", - trigger_dag_id=TRIGGERED_DAG_ID, - execution_date=custom_execution_date, - dag=self.dag, - ) + with pytest.warns( + RemovedInAirflow3Warning, + match="Parameter 'execution_date' is deprecated. Use 'logical_date' instead.", + ): + task = TriggerDagRunOperator( + task_id="test_trigger_dagrun_with_execution_date", + trigger_dag_id=TRIGGERED_DAG_ID, + execution_date=custom_execution_date, + dag=self.dag, + ) task.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) with create_session() as session: