|
50 | 50 | from airflow.utils import timezone
|
51 | 51 | from airflow.utils.session import create_session
|
52 | 52 | from airflow.utils.state import State, TaskInstanceState
|
53 |
| -from airflow.utils.types import DagRunType |
| 53 | +from airflow.utils.types import DagRunTriggeredByType, DagRunType |
54 | 54 |
|
55 | 55 | from tests_common.test_utils.config import conf_vars
|
56 | 56 | from tests_common.test_utils.db import clear_db_pools, clear_db_runs, parse_and_sync_to_db
|
57 |
| -from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS |
58 |
| - |
59 |
| -if AIRFLOW_V_3_0_PLUS: |
60 |
| - from airflow.utils.types import DagRunTriggeredByType |
61 | 57 |
|
62 | 58 | pytestmark = pytest.mark.db_test
|
63 | 59 |
|
@@ -104,21 +100,15 @@ def setup_class(cls):
|
104 | 100 | cls.dagbag = DagBag(read_dags_from_db=True)
|
105 | 101 | cls.dag = cls.dagbag.get_dag(cls.dag_id)
|
106 | 102 | data_interval = cls.dag.timetable.infer_manual_data_interval(run_after=DEFAULT_DATE)
|
107 |
| - v3_kwargs = ( |
108 |
| - { |
109 |
| - "dag_version": None, |
110 |
| - "triggered_by": DagRunTriggeredByType.TEST, |
111 |
| - } |
112 |
| - if AIRFLOW_V_3_0_PLUS |
113 |
| - else {} |
114 |
| - ) |
115 | 103 | cls.dag_run = cls.dag.create_dagrun(
|
116 | 104 | state=State.NONE,
|
117 | 105 | run_id=cls.run_id,
|
118 | 106 | run_type=DagRunType.MANUAL,
|
119 | 107 | logical_date=DEFAULT_DATE,
|
120 | 108 | data_interval=data_interval,
|
121 |
| - **v3_kwargs, |
| 109 | + run_after=DEFAULT_DATE, |
| 110 | + dag_version=None, |
| 111 | + triggered_by=DagRunTriggeredByType.TEST, |
122 | 112 | )
|
123 | 113 |
|
124 | 114 | @classmethod
|
@@ -175,22 +165,16 @@ def test_cli_test_different_path(self, session, tmp_path):
|
175 | 165 |
|
176 | 166 | logical_date = pendulum.now("UTC")
|
177 | 167 | data_interval = dag.timetable.infer_manual_data_interval(run_after=logical_date)
|
178 |
| - v3_kwargs = ( |
179 |
| - { |
180 |
| - "dag_version": None, |
181 |
| - "triggered_by": DagRunTriggeredByType.TEST, |
182 |
| - } |
183 |
| - if AIRFLOW_V_3_0_PLUS |
184 |
| - else {} |
185 |
| - ) |
186 | 168 | dag.create_dagrun(
|
187 | 169 | state=State.NONE,
|
188 | 170 | run_id="abc123",
|
189 | 171 | run_type=DagRunType.MANUAL,
|
190 | 172 | logical_date=logical_date,
|
191 | 173 | data_interval=data_interval,
|
| 174 | + run_after=logical_date, |
| 175 | + dag_version=None, |
| 176 | + triggered_by=DagRunTriggeredByType.TEST, |
192 | 177 | session=session,
|
193 |
| - **v3_kwargs, |
194 | 178 | )
|
195 | 179 | session.commit()
|
196 | 180 |
|
@@ -647,22 +631,16 @@ def test_task_states_for_dag_run(self):
|
647 | 631 | default_date2 = timezone.datetime(2016, 1, 9)
|
648 | 632 | dag2.clear()
|
649 | 633 | data_interval = dag2.timetable.infer_manual_data_interval(run_after=default_date2)
|
650 |
| - v3_kwargs = ( |
651 |
| - { |
652 |
| - "dag_version": None, |
653 |
| - "triggered_by": DagRunTriggeredByType.CLI, |
654 |
| - } |
655 |
| - if AIRFLOW_V_3_0_PLUS |
656 |
| - else {} |
657 |
| - ) |
658 | 634 | dagrun = dag2.create_dagrun(
|
659 | 635 | run_id="test",
|
660 | 636 | state=State.RUNNING,
|
661 | 637 | logical_date=default_date2,
|
662 | 638 | data_interval=data_interval,
|
| 639 | + run_after=default_date2, |
663 | 640 | run_type=DagRunType.MANUAL,
|
664 | 641 | external_trigger=True,
|
665 |
| - **v3_kwargs, |
| 642 | + dag_version=None, |
| 643 | + triggered_by=DagRunTriggeredByType.CLI, |
666 | 644 | )
|
667 | 645 | ti2 = TaskInstance(task2, run_id=dagrun.run_id)
|
668 | 646 | ti2.set_state(State.SUCCESS)
|
@@ -736,22 +714,16 @@ def setup_method(self) -> None:
|
736 | 714 |
|
737 | 715 | dag = DagBag().get_dag(self.dag_id)
|
738 | 716 | data_interval = dag.timetable.infer_manual_data_interval(run_after=self.logical_date)
|
739 |
| - v3_kwargs = ( |
740 |
| - { |
741 |
| - "dag_version": None, |
742 |
| - "triggered_by": DagRunTriggeredByType.TEST, |
743 |
| - } |
744 |
| - if AIRFLOW_V_3_0_PLUS |
745 |
| - else {} |
746 |
| - ) |
747 | 717 | self.dr = dag.create_dagrun(
|
748 | 718 | run_id=self.run_id,
|
749 | 719 | logical_date=self.logical_date,
|
750 | 720 | data_interval=data_interval,
|
| 721 | + run_after=self.logical_date, |
751 | 722 | start_date=timezone.utcnow(),
|
752 | 723 | state=State.RUNNING,
|
753 | 724 | run_type=DagRunType.MANUAL,
|
754 |
| - **v3_kwargs, |
| 725 | + dag_version=None, |
| 726 | + triggered_by=DagRunTriggeredByType.TEST, |
755 | 727 | )
|
756 | 728 | self.tis = self.dr.get_task_instances()
|
757 | 729 | assert len(self.tis) == 1
|
@@ -1049,22 +1021,16 @@ def test_context_with_run():
|
1049 | 1021 | dag = DagBag().get_dag(dag_id)
|
1050 | 1022 | data_interval = dag.timetable.infer_manual_data_interval(run_after=logical_date)
|
1051 | 1023 |
|
1052 |
| - v3_kwargs = ( |
1053 |
| - { |
1054 |
| - "dag_version": None, |
1055 |
| - "triggered_by": DagRunTriggeredByType.TEST, |
1056 |
| - } |
1057 |
| - if AIRFLOW_V_3_0_PLUS |
1058 |
| - else {} |
1059 |
| - ) |
1060 | 1024 | dag.create_dagrun(
|
1061 | 1025 | run_id=run_id,
|
1062 | 1026 | logical_date=logical_date,
|
1063 | 1027 | data_interval=data_interval,
|
| 1028 | + run_after=logical_date, |
1064 | 1029 | start_date=timezone.utcnow(),
|
1065 | 1030 | state=State.RUNNING,
|
1066 | 1031 | run_type=DagRunType.MANUAL,
|
1067 |
| - **v3_kwargs, |
| 1032 | + dag_version=None, |
| 1033 | + triggered_by=DagRunTriggeredByType.TEST, |
1068 | 1034 | )
|
1069 | 1035 | with conf_vars({("core", "dags_folder"): dag_path}):
|
1070 | 1036 | task_command.task_run(parser.parse_args(task_args))
|
|
0 commit comments