Exemplo n.º 1
0
 def test_getData(self):
     """ErrorTraceHelper getData returns expected value when matched"""
     self.eth.error_trace.data = [
         ACSErr.NameValue('badkey', 'badvalue'),
         ACSErr.NameValue('goodkey', 'goodvalue2'),
         ACSErr.NameValue('badkey', 'badvalue')
     ]
     self.assertEqual(['goodvalue2'], self.eth.getData('goodkey'))
Exemplo n.º 2
0
 def test_getData_mulitfind(self):
     """ErrorTraceHelper getData returns expected values for multiple match"""
     self.eth.error_trace.data = [
         ACSErr.NameValue('goodkey', 'goodvalue1'),
         ACSErr.NameValue('badkey', 'badvalue'),
         ACSErr.NameValue('goodkey', 'goodvalue2'),
         ACSErr.NameValue('badkey', 'badvalue')
     ]
     self.assertEqual(['goodvalue1', 'goodvalue2'],
                      self.eth.getData('goodkey'))
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 def _addData(name, value):
     '''
     Adds data to the completions error trace. Will fail if the completion
     is error free.
     '''
     compl_obj.previousError[0].data.append(
         ACSErr.NameValue(str(name), str(value)))
Exemplo n.º 5
0
 def test_errorTraceToString(self):
     """ErrorTraceHelper errorTraceToString creates formatted message"""
     rv = 'ErrorTrace (TimeStamp=Tue Feb  3 21:42:26 2009,\n                File=myfile,\n                Line=myline,\n                Routine=myroutine,\n                Host=myhost,\n                Process=myprocess,\n                Thread=mythread,\n                Type=0,\n                Code=0,\n                ShortDescrip=Description,\n                Severity=Routine,\n                Data: )\n'
     tu = TimeUtil()
     et = ACSErr.ErrorTrace('myfile', 'myline', 'myroutine', 'myhost',
                            'myprocess', 'mythread',
                            tu.py2epoch(1233697346).value, 'mySourceObj', 0,
                            0, 'Routine', 'Description', [], None)
     self.assertEqual(rv, self.eth.errorTraceToString(et, '    '))
Exemplo n.º 6
0
 def test_Print_nested(self):
     """ErrorTraceHelper Print produces output for a nested trace"""
     tu = TimeUtil()
     etg = ACSErr.ErrorTrace('myfile', 'myline', 'myroutine', 'myhost',
                             'grandson', 'mythread',
                             tu.py2epoch(1233697346).value, 'mySourceObj',
                             0, 0, 'Routine', 'Description', [], [])
     ets = ACSErr.ErrorTrace('myfile', 'myline', 'myroutine', 'myhost',
                             'son', 'mythread',
                             tu.py2epoch(1233697346).value, 'mySourceObj',
                             0, 0, 'Routine', 'Description', [], [etg])
     etf = ACSErr.ErrorTrace('myfile', 'myline', 'myroutine', 'myhost',
                             'father', 'mythread',
                             tu.py2epoch(1233697346).value, 'mySourceObj',
                             0, 0, 'Routine', 'Description', [], [ets])
     self.eth = ET.ErrorTraceHelper(etf)
     self.eth.Print()
     self.assertEqual(6, len(sys.stdout.method_calls))
Exemplo n.º 7
0
 def test_object_initialization(self):
     """ErrorTrace initializes with provided data"""
     seq = [
         ACSErr.NameValue('badkey', 'badvalue'),
         ACSErr.NameValue('goodkey', 'goodvalue2'),
         ACSErr.NameValue('badkey', 'badvalue')
     ]
     try:
         raise Exception('Test Exception')
     except Exception, e:
         et = ET.ErrorTrace(0,
                            0,
                            exception=e,
                            description='Test Trace',
                            nvSeq=seq,
                            level=1,
                            severity=ACSErr.Alert,
                            sourceobject='Me')
Exemplo n.º 8
0
 def test_Print(self):
     """ErrorTraceHelper Print produces output for a single trace"""
     tu = TimeUtil()
     et = ACSErr.ErrorTrace('myfile', 'myline', 'myroutine', 'myhost',
                            'myprocess', 'mythread',
                            tu.py2epoch(1233697346).value, 'mySourceObj', 0,
                            0, 'Routine', 'Description', [], [])
     self.eth = ET.ErrorTraceHelper(et)
     self.eth.Print()
     self.assertEqual('write', sys.stdout.method_calls[0][0])
Exemplo n.º 9
0
 def addData(self, name, value):
     '''
     Adds data to the current error
     
     Parameters: name and value will both be converted to strings.
     
     Returns: Nothing
     
     Raises: Nothing    
     '''
     self.getErrorTrace().data.append(
         ACSErr.NameValue(str(name), str(value)))
Exemplo n.º 10
0
 def test_log(self):
     """ErrorTraceHelper log records messages on stdout and ACS logger"""
     rv = 'ErrorTrace (TimeStamp=Tue Feb  3 21:42:26 2009,\n                File=myfile,\n                Line=myline,\n                Routine=myroutine,\n                Host=myhost,\n                Process=myprocess,\n                Thread=mythread,\n                Type=0,\n                Code=0,\n                ShortDescrip=Description,\n                Severity=Routine,\n                Data: )\n'
     logger = mock.Mock(spec=Logger)
     tu = TimeUtil()
     et = ACSErr.ErrorTrace('myfile', 'myline', 'myroutine', 'myhost',
                            'myprocess', 'mythread',
                            tu.py2epoch(1233697346).value, 'mySourceObj', 0,
                            0, 'Routine', 'Description', [], [])
     self.eth = ET.ErrorTraceHelper(et)
     self.eth.log(logger, ACSLog.ACS_LOG_TRACE)
     self.assertEqual('logErrorTrace', logger.method_calls[0][0])
     self.assertEqual(2, len(sys.stdout.method_calls))
Exemplo n.º 11
0
 def test_setData_notlistmember(self):
     """ErrorTraceHelper setData adds pair to a populated list"""
     before = [
         ACSErr.NameValue('goodkey', 'goodvalue1'),
         ACSErr.NameValue('badkey', 'badvalue'),
         ACSErr.NameValue('goodkey', 'goodvalue2'),
         ACSErr.NameValue('badkey', 'badvalue')
     ]
     self.eth.error_trace.data = [
         ACSErr.NameValue('goodkey', 'goodvalue1'),
         ACSErr.NameValue('badkey', 'badvalue'),
         ACSErr.NameValue('goodkey', 'goodvalue2'),
         ACSErr.NameValue('badkey', 'badvalue')
     ]
     self.eth.setData('key', 5.5)
     self.assertNotEquals(1,
                          len(set(before) - set(self.eth.error_trace.data)))
Exemplo n.º 12
0
 def test_setData(self):
     """ErrorTraceHelper setData updates pair in a populated list"""
     self.eth.error_trace.data = [ACSErr.NameValue('goodkey', 'goodvalue1')]
     self.eth.setData('goodkey', 5.5)
     self.assertEqual(['5.5'], self.eth.getData('goodkey'))
Exemplo n.º 13
0
 def test_getData_failedsearch(self):
     """ErrorTraceHelper getData returns expected value for failed search"""
     self.eth.error_trace.data = [ACSErr.NameValue('goodkey', 'goodvalue')]
     self.assertEqual([], self.eth.getData('badkey'))
Exemplo n.º 14
0
 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)