Prab-27 commented on code in PR #50132:
URL: https://github.com/apache/airflow/pull/50132#discussion_r2226173730


##########
airflow-ctl/tests/airflow_ctl/api/test_operations.py:
##########
@@ -114,6 +122,56 @@ def test_server_connection_refused(self):
         ):
             client.connections.get("1")
 
+    @pytest.mark.parametrize(
+        "total_entries, offset, limit, expected_response",
+        [
+            (0, 0, 50, []),
+            (1, 0, 50, [HelloCollectionResponse(hello=["hello"], 
total_entries=1)]),
+            (3, 2, 50, [HelloCollectionResponse(hello=["hello"], 
total_entries=3)]),
+            (
+                20,
+                5,
+                5,
+                [
+                    ("hello", ["hello"]),
+                    ("total_entries", 20),
+                    ("hello", ["hello"]),
+                    ("total_entries", 20),
+                    ("hello", ["hello"]),
+                    ("total_entries", 20),
+                ],
+            ),
+            (2, 3, 50, []),
+        ],
+    )
+    def test_execute_list(self, total_entries, limit, offset, 
expected_response):
+        mock_operation = MagicMock(spec=BaseOperations)
+        mocked_response = []
+        total_entries = total_entries
+        if total_entries < limit:
+            if offset < total_entries:
+                if offset == 0:
+                    
mocked_response.extend([HelloCollectionResponse(hello=["hello"], 
total_entries=1)])
+                    mock_operation.execute_list.return_value = mocked_response
+                elif offset > 0:
+                    
mocked_response.extend([HelloCollectionResponse(hello=["hello"], 
total_entries=3)])
+                    mock_operation.execute_list.return_value = mocked_response
+            else:
+                mocked_response.extend([])
+                mock_operation.execute_list.return_value = mocked_response
+        else:
+            while offset < total_entries:
+                response = HelloCollectionResponse(hello=["hello"], 
total_entries=total_entries)
+                mocked_response.extend(response)
+                offset += limit
+            mock_operation.execute_list.return_value = mocked_response
+        assert (
+            mock_operation.execute_list(
+                path="", data_model=HelloCollectionResponse, offset=offset, 
limit=limit
+            )
+            == expected_response

Review Comment:
   Updated !!



-- 
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