@@ -30,6 +30,7 @@ def list_test_runs(
3030 project_code : str | None = None ,
3131 test_suite : str | None = None ,
3232 table_group_id : str | None = None ,
33+ schedule_id : str | None = None ,
3334 status : str | None = None ,
3435 limit : int = 10 ,
3536 page : int = 1 ,
@@ -43,6 +44,8 @@ def list_test_runs(
4344 test_suite: Optional test suite name to filter by (case-sensitive).
4445 table_group_id: Optional UUID of a table group, e.g. from `get_data_inventory`. Returns
4546 runs for any suite in the group.
47+ schedule_id: Optional UUID of a schedule, e.g. from `list_schedules`. Returns only runs
48+ triggered by that schedule.
4649 status: Optional run status filter. One of: Pending, Running, Completed, Canceled, Error.
4750 limit: Page size (default 10, max 100).
4851 page: Page number starting at 1 (default 1).
@@ -51,6 +54,8 @@ def list_test_runs(
5154 validate_page (page )
5255
5356 statuses = parse_run_status_filter (status ) if status else None
57+ if schedule_id :
58+ parse_uuid (schedule_id , "schedule_id" )
5459
5560 if not project_code and not table_group_id :
5661 raise MCPUserError ("Provide either `project_code` or `table_group_id`." )
@@ -86,6 +91,7 @@ def list_test_runs(
8691 project_code = project_code ,
8792 table_group_id = str (table_group .id ) if table_group else None ,
8893 test_suite_id = test_suite_id ,
94+ schedule_id = schedule_id ,
8995 statuses = statuses ,
9096 page = page ,
9197 page_size = limit ,
@@ -99,10 +105,11 @@ def list_test_runs(
99105 project_code = project_code ,
100106 test_suite_id = test_suite_id ,
101107 table_group_id = str (table_group .id ) if table_group else None ,
108+ schedule_id = schedule_id ,
102109 statuses = statuses ,
103110 )
104111
105- scope_descriptor = _scope_descriptor (project_code , test_suite , table_group_id , status )
112+ scope_descriptor = _scope_descriptor (project_code , test_suite , table_group_id , schedule_id , status )
106113 doc = MdDoc ()
107114 doc .heading (1 , f"Test runs{ scope_descriptor } " )
108115
@@ -199,6 +206,7 @@ def _scope_descriptor(
199206 project_code : str | None ,
200207 test_suite : str | None ,
201208 table_group_id : str | None ,
209+ schedule_id : str | None ,
202210 status : str | None ,
203211) -> str :
204212 parts : list [str ] = []
@@ -208,6 +216,8 @@ def _scope_descriptor(
208216 parts .append (f"suite `{ test_suite } `" )
209217 if table_group_id :
210218 parts .append (f"table group `{ table_group_id } `" )
219+ if schedule_id :
220+ parts .append (f"schedule `{ schedule_id } `" )
211221 if status :
212222 parts .append (f"status `{ status } `" )
213223 return f" — { ', ' .join (parts )} " if parts else ""
@@ -246,6 +256,7 @@ def _select_pending_test_jes(
246256 project_code : str ,
247257 test_suite_id : str | None ,
248258 table_group_id : str | None ,
259+ schedule_id : str | None ,
249260 statuses ,
250261) -> list [JobExecution ]:
251262 """Find queued/in-flight test-run JEs for a given suite or table group scope. For a
@@ -267,7 +278,9 @@ def _select_pending_test_jes(
267278 return []
268279 else :
269280 return []
281+ clauses = [JobExecution .job_schedule_id == schedule_id ] if schedule_id else []
270282 return JobExecution .select_active_by_kwargs (
283+ * clauses ,
271284 project_code = project_code ,
272285 job_key = RUN_TESTS_JOB_KEY ,
273286 kwargs_match = {"test_suite_id" : suite_ids },
0 commit comments