コード例 #1
0
 def test_timeout(self):
     self._run_count = 0
     transaction = NetworkTransaction(initial_backoff_seconds=60*60, timeout_seconds=60)
     did_process_exception = False
     did_throw_exception = True
     try:
         transaction.run(lambda: self._raise_500_error())
         did_throw_exception = False
     except NetworkTimeout, e:
         did_process_exception = True
コード例 #2
0
 def test_exception(self):
     transaction = NetworkTransaction()
     did_process_exception = False
     did_throw_exception = True
     try:
         transaction.run(lambda: self._raise_exception())
         did_throw_exception = False
     except Exception, e:
         did_process_exception = True
         self.assertEqual(e, self.exception)
コード例 #3
0
 def test_exception(self):
     transaction = NetworkTransaction()
     did_process_exception = False
     did_throw_exception = True
     try:
         transaction.run(lambda: self._raise_exception())
         did_throw_exception = False
     except Exception, e:
         did_process_exception = True
         self.assertEqual(e, self.exception)
コード例 #4
0
 def test_timeout(self):
     self._run_count = 0
     transaction = NetworkTransaction(initial_backoff_seconds=60*60, timeout_seconds=60)
     did_process_exception = False
     did_throw_exception = True
     try:
         transaction.run(lambda: self._raise_500_error())
         did_throw_exception = False
     except NetworkTimeout, e:
         did_process_exception = True
コード例 #5
0
 def test_timeout(self):
     transaction = NetworkTransaction(initial_backoff_seconds=60 * 60, timeout_seconds=60)
     did_process_exception = False
     did_throw_exception = True
     try:
         transaction.run(self._raise_500_error)
         did_throw_exception = False
     except NetworkTimeout:
         did_process_exception = True
     self.assertTrue(did_throw_exception)
     self.assertTrue(did_process_exception)
コード例 #6
0
 def test_retry(self):
     transaction = NetworkTransaction(initial_backoff_seconds=0)
     self.assertEqual(transaction.run(self._raise_500_error), 42)
     self.assertEqual(self._run_count, 3)
     self.assertLog(['WARNING: Received HTTP status 500 loading "http://example.com/".  '
                     'Retrying in 0 seconds...\n',
                     'WARNING: Received HTTP status 500 loading "http://example.com/".  '
                     'Retrying in 0.0 seconds...\n'])
コード例 #7
0
 def test_retry(self):
     self._run_count = 0
     transaction = NetworkTransaction(initial_backoff_seconds=0)
     self.assertEqual(transaction.run(lambda: self._raise_500_error()), 42)
     self.assertEqual(self._run_count, 3)
     self.assertLog(['WARNING: Received HTTP status 500 from server.  '
                     'Retrying in 0 seconds...\n',
                     'WARNING: Received HTTP status 500 from server.  '
                     'Retrying in 0.0 seconds...\n'])
コード例 #8
0
 def test_retry(self):
     self._run_count = 0
     transaction = NetworkTransaction(initial_backoff_seconds=0)
     self.assertEqual(transaction.run(lambda: self._raise_http_error()), 42)
     self.assertEqual(self._run_count, 3)
     self.assertLog([
         'WARNING: Received HTTP status 500 from server.  '
         'Retrying in 0 seconds...\n',
         'WARNING: Received HTTP status 500 from server.  '
         'Retrying in 0.0 seconds...\n'
     ])
コード例 #9
0
 def test_retry_on_URLError(self):
     self._run_count = 0
     url = "http://example.com/"
     transaction = NetworkTransaction(initial_backoff_seconds=0)
     self.assertEqual(transaction.run(lambda: self._raise_URLError(), url),
                      43)
     self.assertEqual(self._run_count, 3)
     self.assertLog([
         'WARNING: Received URLError: "[Errno 60] Operation timed out" while loading http://example.com/. '
         'Retrying in 0 seconds...\n',
         'WARNING: Received URLError: "[Errno 60] Operation timed out" while loading http://example.com/. '
         'Retrying in 0.0 seconds...\n'
     ])
コード例 #10
0
 def test_convert_404_to_None(self):
     transaction = NetworkTransaction(convert_404_to_None=True)
     self.assertEqual(transaction.run(lambda: self._raise_404_error()), None)
コード例 #11
0
 def test_success(self):
     transaction = NetworkTransaction()
     self.assertEqual(transaction.run(lambda: 42), 42)
コード例 #12
0
 def test_convert_404_to_None(self):
     transaction = NetworkTransaction(convert_404_to_None=True)
     self.assertEqual(transaction.run(lambda: self._raise_404_error()), None)
コード例 #13
0
 def test_success(self):
     transaction = NetworkTransaction()
     self.assertEqual(transaction.run(lambda: 42), 42)
コード例 #14
0
 def test_convert_404_to_None(self):
     transaction = NetworkTransaction(convert_404_to_None=True)
     self.assertIsNone(transaction.run(self._raise_404_error))