コード例 #1
0
    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))
コード例 #2
0
ファイル: jobsTests.py プロジェクト: igoihman/vdsm
    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'])
コード例 #3
0
ファイル: jobs.py プロジェクト: xin49/vdsm
 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
コード例 #4
0
 def failingCall(self):
     raise exception.GeneralException("Test failure")
コード例 #5
0
ファイル: vmlease_test.py プロジェクト: xin49/vdsm
 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])
コード例 #6
0
 def test_fail_with_general_exception(self):
     exc = ValueError()
     res = self.vm.fail(exc)
     expected = exception.GeneralException(str(exc)).response()
     self.assertEqual(res, expected)