release: Евномия, новая версия, линейка юристов

This commit is contained in:
public-repo-gate
2026-10-19 17:43:00 +03:00
parent 067c6c2414
commit bf1edc117c
239 changed files with 245397 additions and 36598 deletions
+74
View File
@@ -0,0 +1,74 @@
"""Красный тест T451 (12.10.2026): извлечение файлов и проверки номеров в фазе карты идут параллельно.
Перекрытие доказывает Barrier: последовательный проход не соберет всех участников и упадет по таймауту.
"""
import json
import sys
import threading
from pathlib import Path
import pytest
NEXT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(NEXT))
sys.path.insert(0, str(NEXT / "tests"))
import core # noqa: E402
import faza_karta # noqa: E402
from next_helpers import make_case # noqa: E402
@pytest.fixture
def run_(tmp_path):
with core.Run(make_case(tmp_path / "cases" / "c" / "d"), "FAST", "иск") as run:
yield run
def test_izvlechenie_parallel_and_ordered(run_, tmp_path, monkeypatch):
barrier = threading.Barrier(3)
paths = []
for n in range(3):
file = tmp_path / f"f{n}.txt"
file.write_text("x", encoding="utf-8")
paths.append(file)
def tool(run, phase, name, args, ok=(0,), timeout=900):
barrier.wait(timeout=5)
md = Path(args[0]).with_suffix(".md")
md.write_text(f"текст {Path(args[0]).name}", encoding="utf-8")
meta = {"md_path": str(md), "md_chars": 99, "route": "office", "pages": None, "requisites": {}}
return core.Done(0, json.dumps(meta), "", 0)
monkeypatch.setattr(core, "tool", tool)
(run_.dir / "texts").mkdir()
files = faza_karta._ordered(list(enumerate(paths, 1)), lambda job: faza_karta._izvlech(run_, *job))
assert [f["text"] for f in files] == [f"текст f{n}.txt" for n in range(3)]
assert [f["path"].name[:2] for f in files] == ["01", "02", "03"]
def test_izvlechenie_error_stops(run_, tmp_path, monkeypatch):
def tool(run, phase, name, args, ok=(0,), timeout=900):
raise core.Stop("сбой")
monkeypatch.setattr(core, "tool", tool)
with pytest.raises(core.Stop, match="сбой"):
faza_karta._ordered([(1, tmp_path / "a")], lambda job: faza_karta._izvlech(run_, *job))
def test_proverka_nomerov_parallel_and_ordered(run_, monkeypatch):
barrier = threading.Barrier(3)
seen = []
def tool(run, phase, name, args, ok=(0,), timeout=900):
barrier.wait(timeout=5)
seen.append(args[-1])
bad = args[-1] == "1111111111"
return core.Done(1 if bad else 0, "НЕВАЛИДЕН" if bad else "", "", 0)
monkeypatch.setattr(core, "tool", tool)
files = [{"requisites": {"inn": ["1111111111", "2222222222"], "ogrn": ["3333333333333"]}}]
fakty = [{"tema": "ИНН", "znachenie": "1111111111", "status": faza_karta.OK},
{"tema": "ИНН2", "znachenie": "2222222222", "status": faza_karta.OK}]
faza_karta._proverit(run_, files, fakty)
assert sorted(seen) == ["1111111111", "2222222222", "3333333333333"]
assert [f["status"] for f in fakty] == [faza_karta.DISPUTED, faza_karta.OK]