示例#1
0
    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
示例#2
0
    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
示例#3
0
    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
示例#4
0
    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
示例#5
0
    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
示例#6
0
    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