in modules/testrail_script_set_null_automation_status_to_untriaged.py [0:0]
def get_all_test_cases(tr, project_id, suite_id):
"""Fetch all test cases from a suite by handling pagination."""
all_cases = []
offset = 0
limit = 240 # Default limit for TestRail API is 250
while True:
# Build endpoint with pagination parameters
endpoint = (
f"get_cases/{project_id}&suite_id={suite_id}&limit={limit}&offset={offset}"
)
response = tr.client.send_get(endpoint)
cases = response.get("cases", [])
if not cases:
break
all_cases.extend(cases)
# If the number of cases returned is less than the limit, we've reached the last page.
if len(cases) < limit:
break
offset += limit
logging.info(f"Total cases fetched from suite {suite_id}: {len(all_cases)}")
return all_cases