# Copyright (C) 2026 NPO NT
# SPDX-License-Identifier: AGPL-3.0-only

from __future__ import annotations

from mika_deid.ocr import _parse_tsv


HEADER = "level\tpage_num\tblock_num\tpar_num\tline_num\tword_num\tleft\ttop\twidth\theight\tconf\ttext"


def test_tsv_quote_glyph_does_not_swallow_following_name_and_date() -> None:
    tsv = "\n".join(
        [
            HEADER,
            '5\t1\t1\t1\t1\t1\t10\t10\t8\t12\t80\t"',
            "5\t1\t1\t1\t2\t1\t10\t30\t70\t18\t96\tТестова",
            "5\t1\t1\t1\t2\t2\t90\t30\t20\t18\t96\tА.Б.",
            "5\t1\t1\t1\t3\t1\t10\t50\t90\t18\t97\t12.04.1978",
        ]
    )

    tokens, mean = _parse_tsv(tsv, page_index=0)

    assert [token.text for token in tokens] == ['"', "Тестова", "А.Б.", "12.04.1978"]
    assert tokens[1].line_key == (0, 1, 1, 2)
    assert mean == 92.25
