@@ -341,16 +341,16 @@ def test_media_io_base_next_chunk_retries(self):
341
341
upload = MediaIoBaseUpload (
342
342
fd = fd , mimetype = 'image/png' , chunksize = 500 , resumable = True )
343
343
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.
346
346
http = HttpMockSequence ([
347
347
({'status' : '500' }, '' ),
348
348
({'status' : '500' }, '' ),
349
349
({'status' : '503' }, '' ),
350
350
({'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 ' }, '' ),
354
354
({'status' : '200' }, '{}' ),
355
355
])
356
356
@@ -372,6 +372,34 @@ def test_media_io_base_next_chunk_retries(self):
372
372
request .execute (num_retries = 3 )
373
373
self .assertEqual ([20 , 40 , 80 , 20 , 40 , 80 ], sleeptimes )
374
374
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
+
375
403
376
404
class TestMediaIoBaseDownload (unittest .TestCase ):
377
405
0 commit comments