2929 DEFAULT_SAGEMAKER_TRAINING_RETRY_CONFIG ,
3030 SUBMIT_SERVICE_JOB_RESP ,
3131 LIST_SERVICE_JOB_RESP_WITH_JOBS ,
32+ LIST_SERVICE_JOB_BY_SHARE_RESP_WITH_JOBS ,
3233 LIST_SERVICE_JOB_RESP_EMPTY ,
3334 TRAINING_JOB_PAYLOAD ,
3435)
@@ -279,14 +280,14 @@ def test_list_jobs_with_name_filter(self, mock_list_service_job):
279280
280281 # Verify list_service_job was called
281282 mock_list_service_job .assert_called_once ()
282-
283+
283284 # Get the call arguments - list_service_job is called with positional args:
284285 # list_service_job(queue_name, status, filters, next_token)
285286 call_args = mock_list_service_job .call_args [0 ]
286-
287+
287288 # The 3rd positional argument (index 2) is filters
288289 filters = call_args [2 ] if len (call_args ) > 2 else None
289-
290+
290291 # Verify filters contain the job name
291292 assert filters is not None , "Filters should be passed to list_service_job"
292293 assert filters [0 ]["name" ] == "JOB_NAME" , "JOB_NAME filter should be present"
@@ -303,6 +304,56 @@ def test_list_jobs_empty(self, mock_list_service_job):
303304 assert len (jobs ) == 0
304305
305306
307+ class TestTrainingQueueListByShare :
308+ """Tests for TrainingQueue.list_jobs_by_share method"""
309+
310+ @patch ("sagemaker.train.aws_batch.training_queue._list_service_job" )
311+ def test_list_jobs_by_share_default (self , mock_list_service_job ):
312+ """Test list_jobs_by_share with default parameters"""
313+ mock_list_service_job .return_value = iter ([LIST_SERVICE_JOB_BY_SHARE_RESP_WITH_JOBS ])
314+
315+ queue = TrainingQueue (JOB_QUEUE )
316+ jobs = queue .list_jobs_by_share ()
317+
318+ assert len (jobs ) == 2
319+ assert jobs [0 ].share_identifier == SHARE_IDENTIFIER
320+
321+ @patch ("sagemaker.train.aws_batch.training_queue._list_service_job" )
322+ def test_list_jobs_by_share_with_share_filter (self , mock_list_service_job ):
323+ """Test list_jobs_by_share with job name filter"""
324+ mock_list_service_job .return_value = iter ([LIST_SERVICE_JOB_BY_SHARE_RESP_WITH_JOBS ])
325+
326+ queue = TrainingQueue (JOB_QUEUE )
327+ jobs = queue .list_jobs_by_share (share_identifier = SHARE_IDENTIFIER )
328+
329+ # Verify list_service_job was called
330+ mock_list_service_job .assert_called_once ()
331+
332+ # Get the call arguments - list_service_job is called with positional args:
333+ # list_service_job(queue_name, status, filters, next_token)
334+ call_args = mock_list_service_job .call_args [0 ]
335+
336+ # The 3rd positional argument (index 2) is filters
337+ filters = call_args [2 ] if len (call_args ) > 2 else None
338+
339+ # Verify filters contain the share identifier
340+ assert filters is not None , "Filters should be passed to list_service_job"
341+ assert filters [0 ]["name" ] == "SHARE_IDENTIFIER" , "SHARE_IDENTIFIER filter should be present"
342+ assert filters [0 ]["values" ] == [
343+ SHARE_IDENTIFIER
344+ ], "Filter values should contain the share identifier"
345+
346+ @patch ("sagemaker.train.aws_batch.training_queue._list_service_job" )
347+ def test_list_jobs_by_share_empty (self , mock_list_service_job ):
348+ """Test list_jobs_by_share returns empty list"""
349+ mock_list_service_job .return_value = iter ([LIST_SERVICE_JOB_RESP_EMPTY ])
350+
351+ queue = TrainingQueue (JOB_QUEUE )
352+ jobs = queue .list_jobs_by_share ()
353+
354+ assert len (jobs ) == 0
355+
356+
306357class TestTrainingQueueGet :
307358 """Tests for TrainingQueue.get_job method"""
308359
0 commit comments