@@ -341,16 +341,16 @@ def test_media_io_base_next_chunk_retries(self):
341341 upload = MediaIoBaseUpload (
342342 fd = fd , mimetype = 'image/png' , chunksize = 500 , resumable = True )
343343
344- # Simulate 5XXs for both the request that creates the resumable upload and
345- # the upload itself.
344+ # Simulate errors for both the request that creates the resumable upload
345+ # and the upload itself.
346346 http = HttpMockSequence ([
347347 ({'status' : '500' }, '' ),
348348 ({'status' : '500' }, '' ),
349349 ({'status' : '503' }, '' ),
350350 ({'status' : '200' , 'location' : 'location' }, '' ),
351- ({'status' : '500 ' }, '' ),
352- ({'status' : '500 ' }, '' ),
353- ({'status' : '503 ' }, '' ),
351+ ({'status' : '403 ' }, USER_RATE_LIMIT_EXCEEDED_RESPONSE ),
352+ ({'status' : '403 ' }, RATE_LIMIT_EXCEEDED_RESPONSE ),
353+ ({'status' : '429 ' }, '' ),
354354 ({'status' : '200' }, '{}' ),
355355 ])
356356
@@ -372,6 +372,34 @@ def test_media_io_base_next_chunk_retries(self):
372372 request .execute (num_retries = 3 )
373373 self .assertEqual ([20 , 40 , 80 , 20 , 40 , 80 ], sleeptimes )
374374
375+ def test_media_io_base_next_chunk_no_retry_403_not_configured (self ):
376+ fd = BytesIO (b"i am png" )
377+ upload = MediaIoBaseUpload (
378+ fd = fd , mimetype = 'image/png' , chunksize = 500 , resumable = True )
379+
380+ http = HttpMockSequence ([
381+ ({'status' : '403' }, NOT_CONFIGURED_RESPONSE ),
382+ ({'status' : '200' }, '{}' )
383+ ])
384+
385+ model = JsonModel ()
386+ uri = u'https://www.googleapis.com/someapi/v1/upload/?foo=bar'
387+ method = u'POST'
388+ request = HttpRequest (
389+ http ,
390+ model .response ,
391+ uri ,
392+ method = method ,
393+ headers = {},
394+ resumable = upload )
395+
396+ request ._rand = lambda : 1.0
397+ request ._sleep = mock .MagicMock ()
398+
399+ with self .assertRaises (HttpError ):
400+ request .execute (num_retries = 3 )
401+ request ._sleep .assert_not_called ()
402+
375403
376404class TestMediaIoBaseDownload (unittest .TestCase ):
377405
0 commit comments