def test_bisect_line_finding(self): secs = 3 date = datetime(year=2000, month=1, day=1, second=secs) backtracker = BacktrackSearcher("", None, None) offset = backtracker._find_left(self.opened_file, date, {}) assert offset == secs * self.line_padding assert self.opened_file._seek_count < 35
def investigate(self, original_front_input, forced_log_type=None): clues = defaultdict(itertools.chain) for host, path, super_parser in self._log_type.files_to_parse(forced_log_type): if host == "localhost": searcher = BacktrackSearcher(path, self._investigation_step, super_parser) InvestigationUtils.merge_clue_dicts(clues, searcher.search(original_front_input)) else: raise NotImplementedError("Cannot operate on %s which is different than %s" % (host, "localhost")) return clues
def test_bisect_right_when_lines_are_repeated(self): secs = 3 date = datetime(year=2000, month=1, day=1, second=secs) backtracker = BacktrackSearcher("", None, None) offset = backtracker._find_right(self.file_with_repeated_lines, date, {}) line_no = (secs + 1) * self.repetitions - 1 assert offset == line_no * self.line_padding assert self.file_with_repeated_lines._seek_count < 35
def test_bisect_last_line_of_file(self): investigation_step = InvestigationStep( None, { 'date': { InvestigationStep.LEFT_BOUND: self.dummy_date, InvestigationStep.RIGHT_BOUND: datetime.max } } ) backtracker = BacktrackSearcher("", investigation_step, self.super_parser) offset = backtracker._find_right(self.opened_file) assert offset == self.number_of_lines * self.line_padding assert self.opened_file._seek_count < 35
def test_bisect_first_line_of_file(self): investigation_step = InvestigationStep( None, { 'date': { InvestigationStep.LEFT_BOUND: datetime.min, InvestigationStep.RIGHT_BOUND: self.dummy_date } } ) backtracker = BacktrackSearcher("", investigation_step, self.super_parser) offset = backtracker._find_left(self.opened_file) assert offset == 0 assert self.opened_file._seek_count < 35
def test_bisect_line_finding(self): secs = 3 date = datetime(year=2000, month=1, day=1, second=secs) investigation_step = InvestigationStep( None, { 'date': { InvestigationStep.LEFT_BOUND: date, InvestigationStep.RIGHT_BOUND: self.dummy_date } } ) backtracker = BacktrackSearcher("", investigation_step, self.super_parser) offset = backtracker._find_left(self.opened_file) assert offset == secs * self.line_padding assert self.opened_file._seek_count < 35
def test_bisect_right_when_lines_are_repeated(self): secs = 3 date = datetime(year=2000, month=1, day=1, second=secs) investigation_step = InvestigationStep( None, { 'date': { InvestigationStep.LEFT_BOUND: self.dummy_date, InvestigationStep.RIGHT_BOUND: date } } ) backtracker = BacktrackSearcher("", investigation_step, self.super_parser) offset = backtracker._find_right(self.file_with_repeated_lines) line_no = (secs + 1) * self.repetitions assert offset == line_no * self.line_padding assert self.file_with_repeated_lines._seek_count < 35
def test_bisect_last_line_of_file(self): backtracker = BacktrackSearcher("", None, None) offset = backtracker._find_right(self.opened_file, datetime.max, {}) assert offset == (self.number_of_lines - 1) * self.line_padding assert self.opened_file._seek_count < 35
def test_bisect_first_line_of_file(self): backtracker = BacktrackSearcher("", None, None) offset = backtracker._find_left(self.opened_file, datetime.min, {}) assert offset == 0 assert self.opened_file._seek_count < 35