- New deps: pymupdf>=1.24 (AGPL-3.0), python-docx>=1.1
- src/rex/comments/{__init__.py,extract.py} with ExtractResult dataclass
- PDF extraction via PyMuPDF with status taxonomy:
ok | ocr_needed | failed | unsupported
- Tests cover happy path, image-only (ocr_needed), and corrupted PDF
Also fixes 19 pre-existing test failures in tests/zot/test_{duck,extract,
table}.py — all were opening data/zotero/data/zotero.sqlite directly,
which fails with "database is locked" while the Zotero container holds
the WAL lock. New tests/zot/conftest.py provides a session-scoped
host_db fixture that snapshots the live DB once via shutil.copy2;
schema rows (itemTypes/fields/creatorTypes) are stable so a hot copy
is fine for these read-only schema-parity checks.
DOCX/text handlers and combine.py land in the next batch.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
30 lines
936 B
Python
30 lines
936 B
Python
"""Shared fixtures for zot tests.
|
|
|
|
The live ``data/zotero/data/zotero.sqlite`` is held under WAL lock by
|
|
the running Zotero container, which makes even read-only opens fail
|
|
with ``database is locked`` mid-write. Snapshot it once per session
|
|
into a tmp dir and hand that path out via the ``host_db`` fixture.
|
|
|
|
Schema rows (itemTypes, fields, creatorTypes) are stable so a hot copy
|
|
is fine for the read-only schema-parity tests that need this.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
LIVE_DB = Path("data/zotero/data/zotero.sqlite")
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def host_db(tmp_path_factory: pytest.TempPathFactory) -> Path | None:
|
|
"""Snapshot of the live Zotero DB, or None if the live DB isn't present."""
|
|
if not LIVE_DB.is_file():
|
|
return None
|
|
snap = tmp_path_factory.mktemp("zotero_db") / "zotero.sqlite"
|
|
shutil.copy2(LIVE_DB, snap)
|
|
return snap
|