arm-tabular-parser/api/tests/unit/test_fixtures_helpers.py
Andrey Epifancev 38386b53a2 test: доступ к ../fixtures (ARM_KA_FIXTURES), параметризация по 66 ОСВ; зависимости openpyxl/xlrd/pyxlsb
- requirements: openpyxl==3.1.5, pyxlsb==1.0.10, xlrd==2.0.2, et_xmlfile==2.0.0 (транзитивная)
- tests/fixtures_helpers.py, conftest: фикстура fixtures_dir, параметризация osv_file/synthetic_file, skip маркера fixtures
- pyproject: mypy ignore_missing_imports для openpyxl/xlrd/pyxlsb, disallow_untyped_defs для src.parser.*

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vJkmBGKKqMoEMzvsXG3y2
2026-10-05 12:02:40 +04:00

59 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Хелперы доступа к ../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,
)
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"")
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