class ErrorFilterTests(unittest.TestCase): LOG_RECORD = 1 DO_NOT_LOG_RECORD = 0 def setUp(self): self.error_filter = ErrorFilter() def test_should_log_errors(self): error_record = Mock() error_record.levelno = logging.ERROR self.assertEqual( self.error_filter.filter(error_record), self.LOG_RECORD) def test_should_log_warnings(self): warning_record = Mock() warning_record.levelno = logging.WARN self.assertEqual( self.error_filter.filter(warning_record), self.LOG_RECORD) warning_record.levelno = logging.WARNING self.assertEqual( self.error_filter.filter(warning_record), self.LOG_RECORD) def test_should_log_criticals(self): critical_record = Mock() critical_record.levelno = logging.CRITICAL self.assertEqual( self.error_filter.filter(critical_record), self.LOG_RECORD) def test_should_log_fatals(self): fatal_record = Mock() fatal_record.levelno = logging.FATAL self.assertEqual( self.error_filter.filter(fatal_record), self.LOG_RECORD) def test_should_not_log_infos(self): info_record = Mock() info_record.levelno = logging.INFO self.assertEqual(self.error_filter.filter( info_record), self.DO_NOT_LOG_RECORD) def test_should_not_log_debugs(self): debug_record = Mock() debug_record.levelno = logging.DEBUG self.assertEqual(self.error_filter.filter( debug_record), self.DO_NOT_LOG_RECORD)
class ErrorFilterTests(unittest.TestCase): LOG_RECORD = 1 DO_NOT_LOG_RECORD = 0 def setUp(self): self.error_filter = ErrorFilter() def test_should_log_errors(self): error_record = Mock() error_record.levelno = logging.ERROR self.assertEqual(self.error_filter.filter(error_record), self.LOG_RECORD) def test_should_log_warnings(self): warning_record = Mock() warning_record.levelno = logging.WARN self.assertEqual(self.error_filter.filter(warning_record), self.LOG_RECORD) warning_record.levelno = logging.WARNING self.assertEqual(self.error_filter.filter(warning_record), self.LOG_RECORD) def test_should_log_criticals(self): critical_record = Mock() critical_record.levelno = logging.CRITICAL self.assertEqual(self.error_filter.filter(critical_record), self.LOG_RECORD) def test_should_log_fatals(self): fatal_record = Mock() fatal_record.levelno = logging.FATAL self.assertEqual(self.error_filter.filter(fatal_record), self.LOG_RECORD) def test_should_not_log_infos(self): info_record = Mock() info_record.levelno = logging.INFO self.assertEqual(self.error_filter.filter(info_record), self.DO_NOT_LOG_RECORD) def test_should_not_log_debugs(self): debug_record = Mock() debug_record.levelno = logging.DEBUG self.assertEqual(self.error_filter.filter(debug_record), self.DO_NOT_LOG_RECORD)
def setUp(self): self.error_filter = ErrorFilter()