Пример #1
0
 def test1log_atom_not_in_path_list(self):
     """This unittest checks if no action happens, when no path in the match_dictionary matches a target_path."""
     parser_count = ParserCount(self.aminer_config, ['fixed/seq', 'fixed/seq/m1', 'fixed/seq/m2'], [self.stream_printer_event_handler])
     t = time.time()
     log_atom = LogAtom(self.fixed_dme_m3.fixed_data, ParserMatch(self.match_element_m3), t, parser_count)
     old_count_dict = dict(parser_count.count_dict)
     parser_count.receive_atom(log_atom)
     self.assertEqual(parser_count.count_dict, old_count_dict)
Пример #2
0
 def test6receive_atom_without_target_paths(self):
     """This unittest tests the receive_atom method with multiple paths matching without having target_paths specified."""
     parser_count = ParserCount(self.aminer_config, None, [self.stream_printer_event_handler])
     t = time.time()
     log_atom = LogAtom(self.match_context_seq.match_data, ParserMatch(self.match_element_seq), t, parser_count)
     old_count_dict = dict(parser_count.count_dict)
     old_count_dict['fixed/seq'] = {current_processed_lines_str: 1, total_processed_lines_str: 1}
     parser_count.receive_atom(log_atom)
     self.assertEqual(parser_count.count_dict, old_count_dict)
Пример #3
0
 def test2log_atom_matches_single_path(self):
     """This unittest tests the receive_atom method with a single path matching."""
     parser_count = ParserCount(self.aminer_config, ['fixed/seq', 'fixed/seq/m1', 'fixed/seq/m2', 'fixed/m3'],
                                [self.stream_printer_event_handler])
     t = time.time()
     log_atom = LogAtom(self.fixed_dme_m3.fixed_data, ParserMatch(self.match_element_m3), t, parser_count)
     old_count_dict = dict(parser_count.count_dict)
     old_count_dict['fixed/m3'][current_processed_lines_str] = 1
     old_count_dict['fixed/m3'][total_processed_lines_str] = 1
     parser_count.receive_atom(log_atom)
     self.assertEqual(parser_count.count_dict, old_count_dict)
Пример #4
0
 def test4do_timer(self):
     """This unittest checks if the do_timer method works properly."""
     parser_count = ParserCount(self.aminer_config, ['fixed/m3'], [self.stream_printer_event_handler], 600)
     t = time.time()
     self.assertEqual(int(parser_count.do_timer(t + 100)), 600)
     self.assertEqual(self.output_stream.getvalue(), "")
     log_atom = LogAtom(self.match_context_seq.match_data, ParserMatch(self.match_element_seq), t, parser_count)
     parser_count.receive_atom(log_atom)
     self.assertEqual(int(parser_count.do_timer(t + 100)), 500)
     self.assertEqual(self.output_stream.getvalue(), "")
     self.assertEqual(parser_count.do_timer(t + 601), 600)
     self.assertNotEqual(self.output_stream.getvalue(), "")
     self.reset_output_stream()
Пример #5
0
 def test3log_atom_matches_multiple_paths(self):
     """This unittest tests the receive_atom method with multiple paths matching."""
     parser_count = ParserCount(
         self.aminer_config,
         ['fixed/seq', 'fixed/seq/m1', 'fixed/seq/m2', 'fixed/m3'],
         [self.stream_printer_event_handler])
     t = time.time()
     log_atom = LogAtom(self.match_context_seq.match_data,
                        ParserMatch(self.match_element_seq), t,
                        parser_count)
     old_count_dict = dict(parser_count.count_dict)
     old_count_dict['fixed/seq'] = 1
     old_count_dict['fixed/seq/m1'] = 1
     old_count_dict['fixed/seq/m2'] = 1
     parser_count.receive_atom(log_atom)
     self.assertEqual(parser_count.count_dict, old_count_dict)