- golden_helpers, scripts/golden_update.py (--check), test_golden на 66 ОСВ и синтетике; make golden-update/golden-check/test-fixtures - тест покрытия словарей (R-22): счётчик срабатываний Pattern; из osv_headers.yaml удалены неиспользуемые service_columns kpp/code/quantity/currency - синтетика s14–s16 в генераторе и таблице ожиданий; skip вместо падения при отсутствии osv/synthetic (T11.1); комментарий R-21 в s07 (T11.2) - линтер: предел адреса 10 вместо 4 (T3.1), обращение cell(3, 4) (T3.8); реальные файлы не фиксируют BU/RUB (T3.9) - README: golden-процесс; отмечены Task 12 и пункты 4.2, 4.3 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vJkmBGKKqMoEMzvsXG3y2
84 lines
3.1 KiB
Python
84 lines
3.1 KiB
Python
"""Хелперы доступа к ../fixtures: каталог из ARM_KA_FIXTURES, список файлов ОСВ без синтетики, причина skip."""
|
||
|
||
from pathlib import Path
|
||
|
||
import pytest
|
||
from fixtures_helpers import (
|
||
FIXTURES_ENV,
|
||
fixtures_skip_reason,
|
||
osv_fixture_files,
|
||
resolve_fixtures_dir,
|
||
synthetic_files,
|
||
synthetic_skip_reason,
|
||
)
|
||
|
||
|
||
def test_env_overrides_fixtures_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||
monkeypatch.setenv(FIXTURES_ENV, str(tmp_path))
|
||
assert resolve_fixtures_dir() == tmp_path
|
||
|
||
|
||
def test_default_fixtures_dir_is_sibling_of_repository(monkeypatch: pytest.MonkeyPatch) -> None:
|
||
monkeypatch.delenv(FIXTURES_ENV, raising=False)
|
||
assert resolve_fixtures_dir() == Path(__file__).resolve().parents[4] / "fixtures"
|
||
|
||
|
||
def test_no_osv_directory_gives_no_files(tmp_path: Path) -> None:
|
||
assert osv_fixture_files(tmp_path) == []
|
||
assert synthetic_files(tmp_path) == []
|
||
|
||
|
||
def test_synthetic_excluded_and_foreign_files_ignored(tmp_path: Path) -> None:
|
||
osv = tmp_path / "osv"
|
||
(osv / "rb").mkdir(parents=True)
|
||
(osv / "synthetic").mkdir()
|
||
(osv / "rb" / "b.xlsx").write_bytes(b"")
|
||
(osv / "a.xls").write_bytes(b"")
|
||
(osv / "c.xlsb").write_bytes(b"")
|
||
(osv / ".DS_Store").write_bytes(b"")
|
||
(osv / "notes.txt").write_bytes(b"")
|
||
(osv / "synthetic" / "s.xlsx").write_bytes(b"")
|
||
(osv / "synthetic" / ".gitkeep").write_bytes(b"")
|
||
(osv / "synthetic" / "README.md").write_bytes(b"")
|
||
|
||
assert osv_fixture_files(tmp_path) == [osv / "a.xls", osv / "c.xlsb", osv / "rb" / "b.xlsx"]
|
||
assert synthetic_files(tmp_path) == [osv / "synthetic" / "s.xlsx"]
|
||
|
||
|
||
def test_skip_reason_mentions_env_and_path(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||
missing = tmp_path / "нет-такого"
|
||
monkeypatch.setenv(FIXTURES_ENV, str(missing))
|
||
reason = fixtures_skip_reason()
|
||
assert reason is not None
|
||
assert FIXTURES_ENV in reason
|
||
assert str(missing) in reason
|
||
|
||
|
||
def test_skip_reason_none_when_available(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||
(tmp_path / "osv").mkdir()
|
||
monkeypatch.setenv(FIXTURES_ENV, str(tmp_path))
|
||
assert fixtures_skip_reason() is None
|
||
|
||
|
||
def test_synthetic_skip_reason_when_fixtures_exist_but_synthetic_is_missing_or_empty(
|
||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||
) -> None:
|
||
(tmp_path / "osv").mkdir()
|
||
monkeypatch.setenv(FIXTURES_ENV, str(tmp_path))
|
||
reason = synthetic_skip_reason()
|
||
assert reason is not None
|
||
assert "osv" in reason
|
||
assert "synthetic" in reason
|
||
|
||
(tmp_path / "osv" / "synthetic").mkdir()
|
||
(tmp_path / "osv" / "synthetic" / "README.md").write_bytes(b"")
|
||
assert synthetic_skip_reason() == reason
|
||
|
||
(tmp_path / "osv" / "synthetic" / "s01.xlsx").write_bytes(b"")
|
||
assert synthetic_skip_reason() is None
|
||
|
||
|
||
def test_synthetic_skip_reason_is_none_without_fixtures(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||
monkeypatch.setenv(FIXTURES_ENV, str(tmp_path / "нет"))
|
||
assert synthetic_skip_reason() is None # причину тогда даёт fixtures_skip_reason
|