def setUp(self): self.logger = mock.Mock(spec=Logger) self.original = sys.stdout sys.stdout = mock.Mock(spec=sys.stdout) er = Err.ACSError(0, 0) self.cpl = ACSErr.Completion(0, 0, 0, [er.getErrorTrace()]) Err.addComplHelperMethods(self.cpl)
def setUp(self): self.logger = mock.Mock(spec=Logger) self.original = sys.stdout sys.stdout = mock.Mock(spec=sys.stdout) er = Err.ACSError(0,0) self.cpl = ACSErr.Completion(0,0,0,[er.getErrorTrace()]) Err.addComplHelperMethods(self.cpl)
def test_object_initialization_CORBA_Exception(self): """ACSError initialized from CORBA Exception""" try: raise Exception("ACSError Test Exception") except Exception, e: cex = Err.pyExceptionToCORBA(e) er = Err.ACSError(0, 0, exception=cex, create=0) self.assertEqual(er.errorTrace, cex.errorTrace)
def test_object_initialization_nocreate_notraceorprevious(self): """ACSError initialized without create and no trace or previous error""" try: raise Exception("ACSError Test Exception") except Exception, e: er = Err.ACSError(0, 0, exception=5, create=0) self.assertEqual(False, hasattr(er, 'errorTrace'))
def test_object_initialization_CORBA_Exception(self): """ACSError initialized from CORBA Exception""" try: raise Exception("ACSError Test Exception") except Exception, e: cex = Err.pyExceptionToCORBA(e) er = Err.ACSError(0,0,exception=cex,create=0) self.assertEqual(er.errorTrace,cex.errorTrace)
def test_py_exception_to_corb_a(self): """pyExceptionToCORBA creates CORBA exception from Python exception""" try: raise Exception("ACSError Test Exception") except Exception, e: cex = Err.pyExceptionToCORBA(e) self.assertEqual(True, isinstance(cex, PythonExImpl)) self.assertEqual(True, isinstance(cex.errorTrace, Err.ErrorTrace)) self.assertEqual(7, cex.errorTrace.errorType) self.assertEqual(0, cex.errorTrace.errorCode)
def test_object_initialization_Completion(self): """ACSError initialized from Completion""" cpl = ACSErr.Completion(0, 0, 0, [0]) er = Err.ACSError(0, 0, exception=cpl, create=0) self.assertEqual(cpl.previousError[0], er.errorTrace)
def test_object_initialization(self): """ACSError initialized with defaults""" er = Err.ACSError(0, 0) self.assertEqual(True, isinstance(er.errorTrace, Err.ErrorTrace))
def test_getErrorTrace(self): """ACSError getErrorTrace returns trace when defined""" er = Err.ACSError(0, 0) self.assertEqual(True, isinstance(er.errorTrace, Err.ErrorTrace))
def test_getErrorTrace_notrace(self): """ACSError getErrorTrace returns expected value when no trace defined""" er = Err.ACSError(0, 0, create=0) self.assertEqual(True, er.getErrorTrace() is None)