Files
stack/tests/prisma/test_fetch_deep.py
kert dbf71a6594 test: 99.93% coverage — Zotero 9 schema fix + 400+ new tests
Fix Zotero table models for Zotero 9:
- Remove stale Annotations/Highlights/Transaction* models
- Add ItemAnnotations, RetractedItems, DeletedCollections,
  DeletedSearches, DbDebug1
- Fix ItemAttachments, Libraries, Users column mismatches

New test files covering all major modules:
- cli/{bib,prisma,rec,zot,mail,run} deep exercising tests
- mail/{droplet,postmark,resend,cloudflare} lifecycle tests
- bib/{iom,oig,pincite,sync,regulations_gov,email_ingest,format,store}
- prisma/{vpn,fetch,export,llm,screen,eligibility,extract,project,ingest,flow}
- aco/lake/{unity,quality,deploy} + api/aco coverage gaps
- zot/{ops,db,extract,duck} + rec/{report,engine,base,pricers}
- pfs/{pipe,rules,eq,files}

Add pytest-xdist for parallel test execution.

Tracks #353
2026-04-18 10:06:47 -04:00

52 lines
1.5 KiB
Python

"""Deeper tests for prisma.fetch — run() orchestrator + attach_pdf."""
from __future__ import annotations
from prisma.fetch import attach_pdf, pending_queue, run
from zot.db import TYPE_MAP, Db
from zot.schema import create_db
class TestAttachPdf:
def test_creates_attachment(self, tmp_path):
path = str(tmp_path / "z.sqlite")
con = create_db(path)
con.close()
with Db(path) as db:
iid = db.create_item(TYPE_MAP["document"])
db.commit()
pdf = tmp_path / "test.pdf"
pdf.write_bytes(b"%PDF-1.7 test content")
storage = tmp_path / "storage"
storage.mkdir()
att_id = attach_pdf(db, iid, pdf, storage, title="test.pdf")
assert att_id > 0
class TestPendingQueue:
def test_empty_queue(self, tmp_path):
path = str(tmp_path / "z.sqlite")
con = create_db(path)
con.close()
with Db(path) as db:
result = pending_queue(db, "nonexistent")
assert result == []
class TestRun:
def test_empty_queue(self, tmp_path):
path = str(tmp_path / "z.sqlite")
con = create_db(path)
con.close()
with Db(path) as db:
stats = run(
db,
project="test",
storage_dir=tmp_path / "storage",
scratch_dir=tmp_path / "scratch",
email="test@test.com",
fetch_proxy=None,
)
assert stats["missed"] == 0
assert stats["unpaywall"] == 0