Skip to content

Commit

Permalink
Resolve trigger dagrun operator deprecations in tests (apache#40003)
Browse files Browse the repository at this point in the history
* Resolve trigger dagrun operator deprecations in tests

* Fix import order

---------

Co-authored-by: Tzu-ping Chung <[email protected]>
  • Loading branch information
dirrao and uranusjr authored Jun 3, 2024
1 parent bb06c56 commit 9b67a5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
16 changes: 0 additions & 16 deletions tests/deprecations_ignore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 11 additions & 7 deletions tests/operators/test_trigger_dagrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9b67a5e

Please sign in to comment.