コード例 #1
0
 def testRetryFailWithUrlfetchTimeOut(self):
   with mock.patch.object(api_utils.urlfetch, 'fetch') as f:
     f.side_effect = urlfetch.DownloadError
     try:
       api_utils._retry_fetch('foo', self.retry_params)
       self.fail('Should have raised error.')
     except urlfetch.DownloadError:
       self.assertEqual(self.max_retries, f.call_count)
コード例 #2
0
ファイル: api_utils_test.py プロジェクト: sskrab001/dpxdt
 def testRetryFailWithUrlfetchTimeOut(self):
     with mock.patch.object(api_utils.urlfetch, 'fetch') as f:
         f.side_effect = urlfetch.DownloadError
         try:
             api_utils._retry_fetch('foo', self.retry_params)
             self.fail('Should have raised error.')
         except urlfetch.DownloadError:
             self.assertEqual(self.max_retries, f.call_count)
コード例 #3
0
 def testRetryFailWithResponseTimeOut(self):
   self.results.extend([urlfetch.DownloadError()] * (self.max_retries - 1))
   self.results.append(test_utils.MockUrlFetchResult(httplib.REQUEST_TIMEOUT,
                                                     None, None))
   with mock.patch.object(api_utils.urlfetch, 'fetch') as f:
     f.side_effect = self._SideEffect
     self.assertEqual(
         httplib.REQUEST_TIMEOUT,
         api_utils._retry_fetch('foo', self.retry_params).status_code)
コード例 #4
0
ファイル: api_utils_test.py プロジェクト: sskrab001/dpxdt
 def testRetryFailWithResponseTimeOut(self):
     self.results.extend([urlfetch.DownloadError()] *
                         (self.max_retries - 1))
     self.results.append(
         test_utils.MockUrlFetchResult(httplib.REQUEST_TIMEOUT, None, None))
     with mock.patch.object(api_utils.urlfetch, 'fetch') as f:
         f.side_effect = self._SideEffect
         self.assertEqual(
             httplib.REQUEST_TIMEOUT,
             api_utils._retry_fetch('foo', self.retry_params).status_code)
コード例 #5
0
 def testRetrySuccess(self):
   self.results.append(test_utils.MockUrlFetchResult(httplib.REQUEST_TIMEOUT,
                                                     None, None))
   self.results.append(test_utils.MockUrlFetchResult(
       httplib.SERVICE_UNAVAILABLE, None, None))
   self.results.append(urlfetch.DownloadError())
   self.results.append(apiproxy_errors.Error())
   self.results.append(test_utils.MockUrlFetchResult(httplib.ACCEPTED,
                                                     None, None))
   with mock.patch.object(api_utils.urlfetch, 'fetch') as f:
     f.side_effect = self._SideEffect
     self.assertEqual(httplib.ACCEPTED,
                      api_utils._retry_fetch('foo', self.retry_params,
                                             deadline=1000).status_code)
     self.assertEqual(1000, f.call_args[1]['deadline'])
コード例 #6
0
ファイル: api_utils_test.py プロジェクト: sskrab001/dpxdt
 def testRetrySuccess(self):
     self.results.append(
         test_utils.MockUrlFetchResult(httplib.REQUEST_TIMEOUT, None, None))
     self.results.append(
         test_utils.MockUrlFetchResult(httplib.SERVICE_UNAVAILABLE, None,
                                       None))
     self.results.append(urlfetch.DownloadError())
     self.results.append(apiproxy_errors.Error())
     self.results.append(
         test_utils.MockUrlFetchResult(httplib.ACCEPTED, None, None))
     with mock.patch.object(api_utils.urlfetch, 'fetch') as f:
         f.side_effect = self._SideEffect
         self.assertEqual(
             httplib.ACCEPTED,
             api_utils._retry_fetch('foo', self.retry_params,
                                    deadline=1000).status_code)
         self.assertEqual(1000, f.call_args[1]['deadline'])
コード例 #7
0
ファイル: api_utils_test.py プロジェクト: sskrab001/dpxdt
 def testNoRetry(self):
     retry_params = api_utils.RetryParams(max_retries=0)
     self.assertEqual(None, api_utils._retry_fetch('foo', retry_params))
コード例 #8
0
 def testNoRetry(self):
   retry_params = api_utils.RetryParams(max_retries=0)
   self.assertEqual(None, api_utils._retry_fetch('foo', retry_params))