def testLogAborted(self): log = self.testLog() try: raise FakeError() except Exception: self.logger.log_aborted(id(self.job), sys.exc_info()) self.assertIn('FakeError', str(log)) return log
def testGetAbortedActions(self): self.assertEqual(self.logger.get_aborted_actions(), 0) job = FakeJob() self.assertEqual(self.logger.get_aborted_actions(), 0) self.logger.add_log(id(job), job.name, 1) self.assertEqual(self.logger.get_aborted_actions(), 0) self.logger.log_succeeded(id(job)) self.assertEqual(self.logger.get_aborted_actions(), 0) try: raise FakeError() except FakeError: self.logger.log_aborted(id(job), sys.exc_info()) self.assertEqual(self.logger.get_aborted_actions(), 1)
def testGetAbortedLogs(self): self.assertEqual(count(self.logger.get_aborted_logs()), 0) job = FakeJob() self.assertEqual(count(self.logger.get_aborted_logs()), 0) self.logger.add_log(id(job), job.name, 1) self.assertEqual(count(self.logger.get_aborted_logs()), 0) self.logger.log(id(job), 'hello world') self.assertEqual(count(self.logger.get_aborted_logs()), 0) try: raise FakeError() except FakeError: self.logger.log_aborted(id(job), sys.exc_info()) self.assertEqual(count(self.logger.get_succeeded_logs()), 0) self.assertEqual(count(self.logger.get_aborted_logs()), 1) self.assertIsInstance(nth(self.logger.get_aborted_logs(), 0), Log)