test(zot): copy zotero.sqlite to tmp before parity check

Verify-parity opens the DB with PRAGMA journal_mode=WAL, which contends
with the running Zotero container's lock and fails the test with
"database is locked". Snapshot via shutil.copy2 first — schema rows
(itemTypes/fields/creatorTypes) are stable so a hot copy is fine for
this test's purpose.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
kert
2026-04-23 11:11:47 -04:00
parent 16996b43ce
commit 5c446f832e

View File

@@ -118,12 +118,20 @@ class TestFixFields:
class TestVerifyParity: class TestVerifyParity:
def test_with_real_db(self): def test_with_real_db(self, tmp_path):
import shutil
db = Path("data/zotero/data/zotero.sqlite") db = Path("data/zotero/data/zotero.sqlite")
if not db.exists(): if not db.exists():
import pytest import pytest
pytest.skip("zotero.sqlite not available") pytest.skip("zotero.sqlite not available")
result = runner.invoke(app, ["verify-parity", "--db", str(db)]) # Copy to tmp so the parity check (which opens WAL) doesn't
# contend with the Zotero container's lock on the live file.
# Schema rows (itemTypes/fields/creatorTypes) are stable so a
# hot copy is fine for this test's purpose.
snap = tmp_path / "zotero.sqlite"
shutil.copy2(db, snap)
result = runner.invoke(app, ["verify-parity", "--db", str(snap)])
assert result.exit_code == 0 assert result.exit_code == 0
assert "parity OK" in result.output assert "parity OK" in result.output