def test_eval_filter(self): db_events_filter = EventsSeverityChangerFilter( new_severity=Severity.NORMAL, event_class=DatabaseLogEvent) event = DatabaseLogEvent.BAD_ALLOC() self.assertEqual(event.severity, Severity.ERROR) db_events_filter.eval_filter(event) self.assertEqual(event.severity, Severity.NORMAL)
def test_eval_filter_event_class_common_parent(self): filter = EventsFilter(event_class=DatabaseLogEvent) self.assertEqual(filter, pickle.loads(pickle.dumps(filter))) filter.to_json() event1 = DatabaseLogEvent.BAD_ALLOC() event2 = DatabaseLogEvent.NO_SPACE_ERROR() self.assertTrue(filter.eval_filter(event1)) self.assertTrue(filter.eval_filter(event2))
def test_eval_filter_type_with_line_and_node(self): filter = DbEventsFilter(db_event=DatabaseLogEvent.BAD_ALLOC, node="node1", line="y") event1 = DatabaseLogEvent.BAD_ALLOC().add_info(node="node1", line="xyz", line_number=1) event2 = event1.clone().add_info(node="node1", line="abc", line_number=1) event3 = DatabaseLogEvent.NO_SPACE_ERROR().add_info(node="node1", line="xyz", line_number=1) self.assertTrue(filter.eval_filter(event1)) self.assertFalse(filter.eval_filter(event2)) self.assertFalse(filter.eval_filter(event3))
def test_eval_filter_event_class_and_regex(self): filter = EventsFilter(event_class=DatabaseLogEvent.BAD_ALLOC, regex=".*xyz.*") event1 = DatabaseLogEvent.BAD_ALLOC().add_info(node="node1", line="xyz", line_number=1) event2 = DatabaseLogEvent.NO_SPACE_ERROR().add_info(node="node1", line="xyz", line_number=1) event3 = DatabaseLogEvent.NO_SPACE_ERROR().add_info(node="node1", line="abc", line_number=1) self.assertTrue(filter.eval_filter(event1)) self.assertFalse(filter.eval_filter(event2)) self.assertFalse(filter.eval_filter(event3))
def test_eval_filter_event_class(self): db_events_filter = EventsFilter(event_class=DatabaseLogEvent.BAD_ALLOC) self.assertEqual(db_events_filter, pickle.loads(pickle.dumps(db_events_filter))) db_events_filter.to_json() event1 = DatabaseLogEvent.BAD_ALLOC() event2 = DatabaseLogEvent.NO_SPACE_ERROR() self.assertTrue(db_events_filter.eval_filter(event1)) self.assertFalse(db_events_filter.eval_filter(event2))