def test_prn_m_2(self): global expected_log2 # zero bytes min = LogLocation(1507623, datetime(datetime.now().year, 2, 13, 23, 33, 3), LogLocation.TOO_HIGH, LogLocation.TOO_LOW) min.set_is_min(True) max = LogLocation(1507623, datetime(datetime.now().year, 2, 13, 23, 33, 3), LogLocation.TOO_HIGH, LogLocation.TOO_HIGH) # same log, basically max.set_is_min(True) bounds = [min, max] tgrep.print_log_lines(self.mlog_file, bounds, self.log_entries) self.assertEquals(expected_log2, self.log_entries.getvalue())
def test_prn_m_0(self): global expected_log0 # Feb 13 23:33:11 (one log line) # [[1508000, 2011-02-13 23:33:11, 0, 0, True, False], [1508377, 2011-02-13 23:33:15, 1, 1, False, True]] min = LogLocation(1508000, datetime(datetime.now().year, 2, 13, 23, 33, 11), LogLocation.MATCH, LogLocation.MATCH) min.set_is_min(True) max = LogLocation(1508377, datetime(datetime.now().year, 2, 13, 23, 33, 15), LogLocation.TOO_HIGH, LogLocation.TOO_HIGH) max.set_is_min(True) bounds = [min, max] tgrep.print_log_lines(self.mlog_file, bounds, self.log_entries) self.assertEquals(expected_log0, self.log_entries.getvalue())
def test_prn_m_6(self): global expected_log6 # Feb 13 18:30:30 (Start of File, chunk, no exact matches) # [[0, 2011-02-13 18:31:30, 1, -1, True, False], [2639, 2011-02-13 18:32:08, 1, 1, False, True]] min = LogLocation(0, datetime(datetime.now().year, 2, 13, 18, 31, 30), LogLocation.TOO_HIGH, LogLocation.TOO_LOW) min.set_is_min(True) max = LogLocation(2639, datetime(datetime.now().year, 2, 13, 18, 32, 8), LogLocation.TOO_HIGH, LogLocation.TOO_HIGH) max.set_is_min(True) bounds = [min, max] tgrep.print_log_lines(self.mlog_file, bounds, self.log_entries) self.assertEquals(expected_log6, self.log_entries.getvalue())
def test_prn_m_5(self): global expected_log5 # Feb 13 18:31:30 (Start of File, exactly one line) # [[0, 2011-02-13 18:31:30, 0, 0, True, False], [377, 2011-02-13 18:31:36, 1, 1, False, True]] min = LogLocation(0, datetime(datetime.now().year, 2, 13, 18, 31, 30), LogLocation.TOO_LOW, LogLocation.TOO_LOW) min.set_is_min(True) max = LogLocation(377, datetime(datetime.now().year, 2, 13, 18, 31, 36), LogLocation.TOO_HIGH, LogLocation.TOO_HIGH) max.set_is_min(True) bounds = [min, max] tgrep.print_log_lines(self.mlog_file, bounds, self.log_entries) self.assertEquals(expected_log5, self.log_entries.getvalue())
def test_prn_m_4(self): global expected_log4 # Feb 14 07:07:39 (End of File, chunk) # [[3765853, 2011-02-14 07:07:01, 1, -1, True, False], [3770000, 2011-02-14 07:07:39, 1, 1, False, True]] min = LogLocation(3765853, datetime(datetime.now().year, 2, 14, 7, 7, 1), LogLocation.TOO_HIGH, LogLocation.TOO_LOW) min.set_is_min(True) max = LogLocation(3770000, datetime(datetime.now().year, 2, 14, 7, 7, 39), LogLocation.TOO_HIGH, LogLocation.TOO_HIGH) max.set_is_min(True) bounds = [min, max] tgrep.print_log_lines(self.mlog_file, bounds, self.log_entries) self.assertEquals(expected_log4, self.log_entries.getvalue())
def test_prn_m_1(self): global expected_log1 # Feb 13 23:33 (whole minute) # [[1507623, 2011-02-13 23:33:03, 1, -1, True, False], [1512524, 2011-02-13 23:34:03, 1, 1, False, True]] min = LogLocation(1507623, datetime(datetime.now().year, 2, 13, 23, 33, 3), LogLocation.TOO_HIGH, LogLocation.TOO_LOW) min.set_is_min(True) max = LogLocation(1512524, datetime(datetime.now().year, 2, 13, 23, 34, 3), LogLocation.TOO_HIGH, LogLocation.TOO_HIGH) max.set_is_min(True) bounds = [min, max] tgrep.print_log_lines(self.mlog_file, bounds, self.log_entries) self.assertEquals(expected_log1, self.log_entries.getvalue())