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

from __future__ import annotations

import importlib.util
from pathlib import Path

import pytest


MODULE_PATH = Path(__file__).resolve().parents[1] / "scripts" / "evaluate_registry_values.py"
SPEC = importlib.util.spec_from_file_location("evaluate_registry_values", MODULE_PATH)
assert SPEC and SPEC.loader
MODULE = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(MODULE)


def test_normalize_words_handles_cyrillic_and_yo() -> None:
    assert MODULE.normalize_words("Ёлкин Иван Петрович") == ["ЕЛКИН", "ИВАН", "ПЕТРОВИЧ"]


def test_date_digit_variants() -> None:
    assert MODULE.date_digit_variants("1978-04-02") == {
        "02041978",
        "241978",
        "19780402",
        "197842",
    }
    with pytest.raises(ValueError, match="YYYY-MM-DD"):
        MODULE.date_digit_variants("02.04.1978")
