1919 delete_service_by_challenge_pk ,
2020 delete_workers ,
2121 describe_ec2_instance ,
22- ensure_workers_for_host_submission ,
22+ ensure_workers_for_submission ,
2323 get_capacity_provider_strategy ,
2424 get_code_upload_setup_meta_for_challenge ,
2525 get_logs_from_cloudwatch ,
@@ -4798,7 +4798,7 @@ def test_end_date_change_skipped_on_create(self):
47984798 mock_start .assert_not_called ()
47994799
48004800
4801- class TestEnsureWorkersForHostSubmission (TestCase ):
4801+ class TestEnsureWorkersForSubmission (TestCase ):
48024802 @patch ("challenges.aws_utils.settings" )
48034803 def test_returns_early_in_debug_mode (self , mock_settings ):
48044804 """Should return early without calling start_workers in DEBUG mode."""
@@ -4807,7 +4807,7 @@ def test_returns_early_in_debug_mode(self, mock_settings):
48074807 challenge .pk = 1
48084808
48094809 with patch ("challenges.aws_utils.start_workers" ) as mock_start :
4810- ensure_workers_for_host_submission (challenge )
4810+ ensure_workers_for_submission (challenge )
48114811 mock_start .assert_not_called ()
48124812
48134813 @patch ("challenges.aws_utils.settings" )
@@ -4819,7 +4819,7 @@ def test_returns_early_in_test_mode(self, mock_settings):
48194819 challenge .pk = 1
48204820
48214821 with patch ("challenges.aws_utils.start_workers" ) as mock_start :
4822- ensure_workers_for_host_submission (challenge )
4822+ ensure_workers_for_submission (challenge )
48234823 mock_start .assert_not_called ()
48244824
48254825 @patch ("challenges.aws_utils.settings" )
@@ -4834,7 +4834,7 @@ def test_returns_early_for_docker_based_challenge(self, mock_settings):
48344834 challenge .remote_evaluation = False
48354835
48364836 with patch ("challenges.aws_utils.start_workers" ) as mock_start :
4837- ensure_workers_for_host_submission (challenge )
4837+ ensure_workers_for_submission (challenge )
48384838 mock_start .assert_not_called ()
48394839
48404840 @patch ("challenges.aws_utils.settings" )
@@ -4849,7 +4849,7 @@ def test_returns_early_for_ec2_challenge(self, mock_settings):
48494849 challenge .remote_evaluation = False
48504850
48514851 with patch ("challenges.aws_utils.start_workers" ) as mock_start :
4852- ensure_workers_for_host_submission (challenge )
4852+ ensure_workers_for_submission (challenge )
48534853 mock_start .assert_not_called ()
48544854
48554855 @patch ("challenges.aws_utils.settings" )
@@ -4866,7 +4866,7 @@ def test_returns_early_for_remote_evaluation_challenge(
48664866 challenge .remote_evaluation = True
48674867
48684868 with patch ("challenges.aws_utils.start_workers" ) as mock_start :
4869- ensure_workers_for_host_submission (challenge )
4869+ ensure_workers_for_submission (challenge )
48704870 mock_start .assert_not_called ()
48714871
48724872 @patch ("challenges.aws_utils.settings" )
@@ -4882,13 +4882,12 @@ def test_returns_early_when_workers_already_exist(self, mock_settings):
48824882 challenge .workers = 1 # Workers already exist
48834883
48844884 with patch ("challenges.aws_utils.start_workers" ) as mock_start :
4885- ensure_workers_for_host_submission (challenge )
4885+ ensure_workers_for_submission (challenge )
48864886 mock_start .assert_not_called ()
48874887
48884888 @patch ("challenges.aws_utils.settings" )
4889- def test_returns_early_when_workers_stopped (self , mock_settings ):
4890- """Should be a no-op when workers are stopped (0) since
4891- auto-scaling will handle scale-up."""
4889+ def test_starts_workers_when_workers_stopped (self , mock_settings ):
4890+ """Should start workers when workers are stopped (0)."""
48924891 mock_settings .DEBUG = False
48934892 mock_settings .TEST = False
48944893 challenge = MagicMock ()
@@ -4899,8 +4898,9 @@ def test_returns_early_when_workers_stopped(self, mock_settings):
48994898 challenge .workers = 0 # Workers exist but stopped
49004899
49014900 with patch ("challenges.aws_utils.start_workers" ) as mock_start :
4902- ensure_workers_for_host_submission (challenge )
4903- mock_start .assert_not_called ()
4901+ mock_start .return_value = {"count" : 1 , "failures" : []}
4902+ ensure_workers_for_submission (challenge )
4903+ mock_start .assert_called_once_with ([challenge ])
49044904
49054905 @patch ("challenges.aws_utils.start_workers" )
49064906 @patch ("challenges.aws_utils.settings" )
@@ -4919,7 +4919,7 @@ def test_creates_workers_when_none_exist(
49194919
49204920 mock_start_workers .return_value = {"count" : 1 , "failures" : []}
49214921
4922- ensure_workers_for_host_submission (challenge )
4922+ ensure_workers_for_submission (challenge )
49234923
49244924 mock_start_workers .assert_called_once_with ([challenge ])
49254925
@@ -4946,7 +4946,7 @@ def test_logs_error_when_worker_creation_fails(
49464946 }
49474947
49484948 # Should not raise, just log the error
4949- ensure_workers_for_host_submission (challenge )
4949+ ensure_workers_for_submission (challenge )
49504950
49514951 mock_start_workers .assert_called_once_with ([challenge ])
49524952
0 commit comments