def test_should_be_possible_to_add_csv_files(self): csvlogs = CsvLogs() for i in range(3): csvlogs.add(self._log_files[i]) result = self._write_to_file_and_read_back_result(csvlogs) expected_result = """#,Time,Level,File,Line,Source,Message 0,10 fs,info,bar.vhd,17,src1,This is an info entry. 4,100 fs,info,zoo.vhd,17,src3,This is an info entry. 10,20 ps,failure,foo.vhd,42,src2,This is a failure entry. 21,30 ns,error,foo.vhd,42,src2,This is an error entry. 30,50 ns,failure,ying.vhd,42,src4,This is a failure entry. 31,70 ns,error,yang.vhd,42,src5,This is an error entry. """ self.assertEqual(result, expected_result)
def test_should_be_possible_to_add_csv_files(self): csvlogs = CsvLogs() for i in range(3): csvlogs.add(self._log_files[i]) result = self._write_to_file_and_read_back_result(csvlogs) expected_result = """#,Time,Level,File,Line,Source,Message 0,10 fs,info,bar.vhd,17,src1,This is an info entry. 4,100 fs,info,zoo.vhd,17,src3,This is an info entry. 10,20 ps,failure,foo.vhd,42,src2,This is a failure entry. 21,30 ns,error,foo.vhd,42,src2,This is an error entry. 30,50 ns,failure,ying.vhd,42,src4,This is a failure entry. 31,70 ns,error,yang.vhd,42,src5,This is an error entry. """ self.assertEqual(result, expected_result)
def test_should_sort_single_empty_csv_file(self): csvlogs = CsvLogs(self._log_files[1]) result = self._write_to_file_and_read_back_result(csvlogs) expected_result = """#,Time,Level,File,Line,Source,Message """ self.assertEqual(result, expected_result)
def test_should_sort_single_csv_file(self): csvlogs = CsvLogs(self._log_files[0]) result = self._write_to_file_and_read_back_result(csvlogs) expected_result = """#,Time,Level,File,Line,Source,Message 0,10 fs,info,bar.vhd,17,src1,This is an info entry. 10,20 ps,failure,foo.vhd,42,src2,This is a failure entry. 21,30 ns,error,foo.vhd,42,src2,This is an error entry. """ self.assertEqual(result, expected_result)
def test_should_sort_several_csv_files_with_non_default_fields(self): csvlogs = CsvLogs(self._few_fields_files, ['#', 'Time', 'Level', 'Source', 'Message']) result = self._write_to_file_and_read_back_result(csvlogs) expected_result = """#,Time,Level,Source,Message 0,10 fs,info,src1,This is an info entry. 4,100 fs,info,src3,This is an info entry. 10,20 ps,failure,src2,This is a failure entry. 21,30 ns,error,src2,This is an error entry. 30,50 ns,failure,src4,This is a failure entry. 31,70 ns,error,src5,This is an error entry. """ self.assertEqual(result, expected_result)
def test_should_sort_several_csv_files(self): c = CsvLogs(self._all_fields_files) result = self._write_to_file_and_read_back_result(c) expected_result = """#,Time,Level,File,Line,Source,Message 0,10 fs,info,bar.vhd,17,src1,This is an info entry. 4,100 fs,info,zoo.vhd,17,src3,This is an info entry. 10,20 ps,failure,foo.vhd,42,src2,This is a failure entry. 21,30 ns,error,foo.vhd,42,src2,This is an error entry. 30,50 ns,failure,ying.vhd,42,src4,This is a failure entry. 31,70 ns,error,yang.vhd,42,src5,This is an error entry. """ self.assertEqual(result, expected_result)