@@ -128,7 +128,6 @@ def request(self, *args, **kwargs):
128128 ex = TimeoutError ()
129129 else :
130130 ex = socket .error ()
131-
132131 if self .num_errors == 2 :
133132 #first try a broken pipe error (#218)
134133 ex .errno = socket .errno .EPIPE
@@ -739,6 +738,20 @@ def test_media_io_base_download_empty_file(self):
739738 }
740739}"""
741740
741+ LIST_NOT_CONFIGURED_RESPONSE = """[
742+ "error": {
743+ "errors": [
744+ {
745+ "domain": "usageLimits",
746+ "reason": "accessNotConfigured",
747+ "message": "Access Not Configured"
748+ }
749+ ],
750+ "code": 403,
751+ "message": "Access Not Configured"
752+ }
753+ ]"""
754+
742755class Callbacks (object ):
743756 def __init__ (self ):
744757 self .responses = {}
@@ -956,6 +969,29 @@ def test_no_retry_401_fails_fast(self):
956969 request .execute ()
957970 request ._sleep .assert_not_called ()
958971
972+ def test_no_retry_403_list_fails (self ):
973+ http = HttpMockSequence ([
974+ ({'status' : '403' }, LIST_NOT_CONFIGURED_RESPONSE ),
975+ ({'status' : '200' }, '{}' )
976+ ])
977+ model = JsonModel ()
978+ uri = u'https://www.googleapis.com/someapi/v1/collection/?foo=bar'
979+ method = u'POST'
980+ request = HttpRequest (
981+ http ,
982+ model .response ,
983+ uri ,
984+ method = method ,
985+ body = u'{}' ,
986+ headers = {'content-type' : 'application/json' })
987+
988+ request ._rand = lambda : 1.0
989+ request ._sleep = mock .MagicMock ()
990+
991+ with self .assertRaises (HttpError ):
992+ request .execute ()
993+ request ._sleep .assert_not_called ()
994+
959995class TestBatch (unittest .TestCase ):
960996
961997 def setUp (self ):
0 commit comments