josix commented on code in PR #46279:
URL: https://github.com/apache/airflow/pull/46279#discussion_r1935419663


##########
tests/api_fastapi/core_api/routes/ui/test_structure.py:
##########
@@ -81,6 +132,28 @@ def make_dag(dag_maker, session, time_machine):
     dag_maker.sync_dagbag_to_db()
 
 
[email protected]
+def make_dag_with_multiple_version(dag_maker, session):
+    with dag_maker(DAG_ID) as dag:
+        EmptyOperator(task_id="task1")
+    dag.sync_to_db()
+    SerializedDagModel.write_dag(dag, bundle_name="dag_maker")
+    with dag_maker(DAG_ID) as dag2:
+        EmptyOperator(task_id="task1")
+        EmptyOperator(task_id="task2")
+    dag2.sync_to_db()
+    SerializedDagModel.write_dag(dag2, bundle_name="dag_maker")
+    with dag_maker(DAG_ID) as dag3:
+        EmptyOperator(task_id="task1")
+        EmptyOperator(task_id="task2")
+        EmptyOperator(task_id="task3")
+    dag3.sync_to_db()
+    SerializedDagModel.write_dag(dag3, bundle_name="dag_maker")
+
+    latest_version = DagVersion.get_latest_version(dag.dag_id)

Review Comment:
   nit. how about turning the duplicated works into one `create_dag_version` 
function.
   ```suggestion
       def create_dag_version(version: int) -> None:
           """Create a DAG with increasing number of tasks based on version 
number."""
           with dag_maker(DAG_ID) as dag:
               for i in range(1, version + 1):
                   EmptyOperator(task_id=f"task{i}")
           dag.sync_to_db()
           SerializedDagModel.write_dag(dag, bundle_name="dag_maker")
           return dag
   
       for version in range(1, 4):
           dag = create_dag_version(version)
   
       latest_version = DagVersion.get_latest_version(dag.dag_id)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to