rawwar commented on code in PR #42870:
URL: https://github.com/apache/airflow/pull/42870#discussion_r1818573244
##########
tests/api_connexion/endpoints/test_task_instance_endpoint.py:
##########
@@ -1032,6 +1032,56 @@ def
test_should_raise_400_for_naive_and_bad_datetime(self, payload, expected, se
assert response.status_code == 400
assert expected in response.json["detail"]
+ def test_should_respond_200_for_pagination(self, session):
+ dag_id = "example_python_operator"
+
+ self.create_task_instances(
+ session,
+ task_instances=[
+ {"start_date": DEFAULT_DATETIME_1 + dt.timedelta(minutes=(i +
1))} for i in range(10)
+ ],
+ dag_id=dag_id,
+ )
+
+ # First 5 items
+ response_batch1 = self.client.post(
+ "/api/v1/dags/~/dagRuns/~/taskInstances/list",
+ environ_overrides={"REMOTE_USER": "test"},
+ json={"page_limit": 5, "page_offset": 0},
+ )
+ assert response_batch1.status_code == 200, response_batch1.json
+ num_entries_batch1 = len(response_batch1.json["task_instances"])
+ assert num_entries_batch1 == 5
+ assert len(response_batch1.json["task_instances"]) == 5
+
+ # 5 items after that
+ response_batch2 = self.client.post(
+ "/api/v1/dags/~/dagRuns/~/taskInstances/list",
+ environ_overrides={"REMOTE_USER": "test"},
+ json={"page_limit": 5, "page_offset": 5},
+ )
+ assert response_batch2.status_code == 200, response_batch2.json
+ num_entries_batch2 = len(response_batch2.json["task_instances"])
+ assert num_entries_batch2 > 0
+ assert len(response_batch2.json["task_instances"]) > 0
+
+ # Match
+ ti_count = session.query(TaskInstance).filter(TaskInstance.dag_id ==
dag_id).count()
Review Comment:
I accidentally committed this. But, this won't be equal to 10. It will be
equal to 9 as they are only creating from id 1 to 9
--
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]