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 update_status(self, queue_name, status, patch=None, results_file=None): # During unit testing, host is None if not self.host: return log(status) return NetworkTransaction().run(lambda: self._post_to_server( queue_name, status, patch, results_file))
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)