Skip to content

Commit

Permalink
Resolve core operators deprecations in tests (apache#39992)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirrao authored Jun 5, 2024
1 parent 16e0182 commit f28ee5a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
14 changes: 0 additions & 14 deletions tests/deprecations_ignore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,6 @@


# Operators
- tests/operators/test_bash.py::TestBashOperator::test_echo_env_variables
- tests/operators/test_branch_operator.py::TestBranchOperator::test_with_dag_run
- tests/operators/test_branch_operator.py::TestBranchOperator::test_with_skip_in_branch_downstream_dependencies
- tests/operators/test_branch_operator.py::TestBranchOperator::test_xcom_push
- tests/operators/test_datetime.py::TestBranchDateTimeOperator::test_branch_datetime_operator_falls_outside_range
- tests/operators/test_datetime.py::TestBranchDateTimeOperator::test_branch_datetime_operator_falls_within_range
- tests/operators/test_datetime.py::TestBranchDateTimeOperator::test_branch_datetime_operator_lower_comparison_outside_range
- tests/operators/test_datetime.py::TestBranchDateTimeOperator::test_branch_datetime_operator_lower_comparison_within_range
- tests/operators/test_datetime.py::TestBranchDateTimeOperator::test_branch_datetime_operator_upper_comparison_outside_range
- tests/operators/test_datetime.py::TestBranchDateTimeOperator::test_branch_datetime_operator_upper_comparison_within_range
- tests/operators/test_datetime.py::TestBranchDateTimeOperator::test_branch_datetime_operator_use_task_logical_date
- tests/operators/test_datetime.py::TestBranchDateTimeOperator::test_deprecation_warning
- tests/operators/test_datetime.py::TestBranchDateTimeOperator::test_no_target_time
- tests/operators/test_latest_only_operator.py::TestLatestOnlyOperator::test_not_skipping_external
- tests/operators/test_latest_only_operator.py::TestLatestOnlyOperator::test_skipping_non_latest
- tests/operators/test_subdag_operator.py::TestSubDagOperator::test_execute_create_dagrun_wait_until_success
- tests/operators/test_subdag_operator.py::TestSubDagOperator::test_execute_create_dagrun_with_conf
Expand Down
4 changes: 3 additions & 1 deletion tests/operators/test_bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ def test_echo_env_variables(self, append_env, user_defined_env, expected_airflow
dagrun_timeout=timedelta(minutes=60),
)

execution_date = utc_now
dag.create_dagrun(
run_type=DagRunType.MANUAL,
execution_date=utc_now,
execution_date=execution_date,
start_date=utc_now,
state=State.RUNNING,
external_trigger=False,
data_interval=(execution_date, execution_date),
)

tmp_file = tmp_path / "testfile"
Expand Down
4 changes: 4 additions & 0 deletions tests/operators/test_branch_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def test_with_dag_run(self):
start_date=timezone.utcnow(),
execution_date=DEFAULT_DATE,
state=State.RUNNING,
data_interval=(DEFAULT_DATE, DEFAULT_DATE),
)

self.branch_op.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE)
Expand All @@ -164,6 +165,7 @@ def test_with_skip_in_branch_downstream_dependencies(self):
start_date=timezone.utcnow(),
execution_date=DEFAULT_DATE,
state=State.RUNNING,
data_interval=(DEFAULT_DATE, DEFAULT_DATE),
)

self.branch_op.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE)
Expand All @@ -189,6 +191,7 @@ def test_xcom_push(self):
start_date=timezone.utcnow(),
execution_date=DEFAULT_DATE,
state=State.RUNNING,
data_interval=(DEFAULT_DATE, DEFAULT_DATE),
)

self.branch_op.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE)
Expand All @@ -215,6 +218,7 @@ def test_with_dag_run_task_groups(self):
start_date=timezone.utcnow(),
execution_date=DEFAULT_DATE,
state=State.RUNNING,
data_interval=(DEFAULT_DATE, DEFAULT_DATE),
)

self.branch_op.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE)
Expand Down
7 changes: 6 additions & 1 deletion tests/operators/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ def setup_method(self):
self.dag.clear()

self.dr = self.dag.create_dagrun(
run_id="manual__", start_date=DEFAULT_DATE, execution_date=DEFAULT_DATE, state=State.RUNNING
run_id="manual__",
start_date=DEFAULT_DATE,
execution_date=DEFAULT_DATE,
state=State.RUNNING,
data_interval=(DEFAULT_DATE, DEFAULT_DATE),
)

def teardown_method(self):
Expand Down Expand Up @@ -236,6 +240,7 @@ def test_branch_datetime_operator_use_task_logical_date(self, target_lower, targ
start_date=in_between_date,
execution_date=in_between_date,
state=State.RUNNING,
data_interval=(in_between_date, in_between_date),
)

self.branch_op.target_lower = target_lower
Expand Down
6 changes: 5 additions & 1 deletion tests/operators/test_latest_only_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,17 @@ def test_not_skipping_external(self):
execution_date=DEFAULT_DATE,
state=State.RUNNING,
external_trigger=True,
data_interval=(DEFAULT_DATE, DEFAULT_DATE),
)

execution_date = timezone.datetime(2016, 1, 1, 12)
self.dag.create_dagrun(
run_type=DagRunType.MANUAL,
start_date=timezone.utcnow(),
execution_date=timezone.datetime(2016, 1, 1, 12),
execution_date=execution_date,
state=State.RUNNING,
external_trigger=True,
data_interval=(execution_date, execution_date),
)

self.dag.create_dagrun(
Expand All @@ -179,6 +182,7 @@ def test_not_skipping_external(self):
execution_date=END_DATE,
state=State.RUNNING,
external_trigger=True,
data_interval=(END_DATE, END_DATE),
)

latest_task.run(start_date=DEFAULT_DATE, end_date=END_DATE)
Expand Down

0 comments on commit f28ee5a

Please sign in to comment.