def test_failing_call(self): with self._create_client() as client: with self.assertRaises(ServerError) as ex: client.Test.failingCall() self.assertEqual(ex.exception.code, exception.GeneralException().code) self.assertIn("Test failure", str(ex.exception))
def test_job_get_error(self): job = TestingJob() self.assertIsNone(job.error) self.assertNotIn('error', job.info()) error = exception.GeneralException() job._error = error self.assertEqual(job.error, error) self.assertEqual(error.info(), job.info()['error'])
def _run_failed(self, e): """ The job's _run method failed and raised an exception. If we were in the process of aborting we consider the abort operation finished. Otherwise, move the job to failed state. """ with self._status_lock: if self.status == STATUS.ABORTING: self._status = STATUS.ABORTED logging.exception("Exception while aborting job %r", self.id) else: self._status = STATUS.FAILED logging.exception("Job %r failed", self.id) if not isinstance(e, exception.VdsmException): e = exception.GeneralException(str(e)) self._error = e
def failingCall(self): raise exception.GeneralException("Test failure")
def lease_info(self, lease): key = (lease["sd_id"], lease["lease_id"]) if key not in self.leases: return exception.GeneralException().response() return response.success(result=self.leases[key])
def test_fail_with_general_exception(self): exc = ValueError() res = self.vm.fail(exc) expected = exception.GeneralException(str(exc)).response() self.assertEqual(res, expected)