prabhusneha commented on code in PR #45802: URL: https://github.com/apache/airflow/pull/45802#discussion_r1925981556
########## tests/api_fastapi/core_api/routes/public/test_task_instances.py: ########## @@ -1034,38 +1034,67 @@ def test_should_respond_200_for_dag_id_filter(self, test_client, session): def test_should_respond_200_for_order_by(self, test_client, session): dag_id = "example_python_operator" + + dag_runs = [ + DagRun( + dag_id=dag_id, + run_id=f"run_{i}", + run_type=DagRunType.MANUAL, + logical_date=DEFAULT_DATETIME_1 + dt.timedelta(days=i), + data_interval=( + DEFAULT_DATETIME_1 + dt.timedelta(days=i), + DEFAULT_DATETIME_1 + dt.timedelta(days=i, hours=1), + ), + ) + for i in range(10) + ] + session.add_all(dag_runs) + session.commit() + self.create_task_instances( session, task_instances=[ - {"start_date": DEFAULT_DATETIME_1 + dt.timedelta(minutes=(i + 1))} for i in range(10) + {"run_id": f"run_{i}", "start_date": DEFAULT_DATETIME_1 + dt.timedelta(minutes=(i + 1))} + for i in range(10) ], dag_id=dag_id, ) ti_count = session.query(TaskInstance).filter(TaskInstance.dag_id == dag_id).count() - # Ascending order - response_asc = test_client.get( - "/public/dags/~/dagRuns/~/taskInstances", params={"order_by": "start_date"} - ) - assert response_asc.status_code == 200 - assert response_asc.json()["total_entries"] == ti_count - assert len(response_asc.json()["task_instances"]) == ti_count - - # Descending order - response_desc = test_client.get( - "/public/dags/~/dagRuns/~/taskInstances", params={"order_by": "-start_date"} - ) - assert response_desc.status_code == 200 - assert response_desc.json()["total_entries"] == ti_count - assert len(response_desc.json()["task_instances"]) == ti_count + for field in ["start_date", "logical_date", "data_interval_start", "data_interval_end"]: + # Ascending order Review Comment: parametrized the order by tests for task instances and mapped task instances ########## airflow/api_fastapi/core_api/routes/public/task_instances.py: ########## @@ -419,6 +433,7 @@ def get_task_instances( limit=limit, session=session, ) + print(task_instance_select) Review Comment: removed -- 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: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org