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_http_error()) did_throw_exception = False except NetworkTimeout, e: did_process_exception = True
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)
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)
def test_success(self): transaction = NetworkTransaction() self.assertEqual(transaction.run(lambda: 42), 42)