@@ -216,6 +216,43 @@ def __init__(self):
216
216
with self .assertRaises (GokartBuildError ):
217
217
gokart .build (_DummyTask (param = 'test' ), reset_register = False , log_level = logging .CRITICAL )
218
218
219
+ def test_build_not_raises_exception_when_success_with_retry (self ):
220
+ """Test that build() does not raise GokartBuildError when task succeeds with retry"""
221
+
222
+ # Create a mock result object with SUCCESS_WITH_RETRY status
223
+ class MockResult :
224
+ def __init__ (self ):
225
+ self .status = luigi .LuigiStatusCode .SUCCESS_WITH_RETRY
226
+ self .summary_text = 'Task completed successfully after retries'
227
+
228
+ # Mock _build_task to return a test value directly
229
+ with patch ('luigi.build' ) as mock_luigi_build :
230
+ mock_luigi_build .return_value = MockResult ()
231
+
232
+ # Create a mock task that will be used by build()
233
+ mock_task = _DummyTask (param = 'test' )
234
+
235
+ # This should not raise GokartBuildError
236
+ # The test output will be whatever the mock returns
237
+ gokart .build (mock_task , reset_register = False , return_value = False , log_level = logging .CRITICAL )
238
+
239
+ def test_build_not_raises_exception_on_scheduling_failed_only (self ):
240
+ """Test that build() raises GokartBuildError when SCHEDULING_FAILED occurs"""
241
+
242
+ # Create a mock result object with SCHEDULING_FAILED status
243
+ class MockResult :
244
+ def __init__ (self ):
245
+ self .status = luigi .LuigiStatusCode .SCHEDULING_FAILED
246
+ self .summary_text = 'Task scheduling failed'
247
+
248
+ # Mock luigi.build to return SCHEDULING_FAILED status
249
+ with patch ('luigi.build' ) as mock_luigi_build :
250
+ mock_luigi_build .return_value = MockResult ()
251
+
252
+ # This should raise GokartBuildError after the fix
253
+ with self .assertRaises (GokartBuildError ):
254
+ gokart .build (_DummyTask (param = 'test' ), reset_register = False , log_level = logging .CRITICAL )
255
+
219
256
220
257
if __name__ == '__main__' :
221
258
unittest .main ()
0 commit comments