Files
stack/tests/bib/test_sync_exercise.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

57 lines
1.6 KiB
Python

"""Exercise push_to_zotero with real DB."""
from __future__ import annotations
from unittest.mock import MagicMock
from bib.item import Rule, Source
from bib.sync import push_to_zotero
from zot.schema import create_db
class TestPushToZotero:
def test_pushes_source(self, tmp_path):
zot_path = str(tmp_path / "z.sqlite")
con = create_db(zot_path)
con.close()
store = MagicMock()
store._con.return_value.execute.return_value.fetchall.return_value = []
items = [
Source(
key="SRCKEY01",
title="Test Source",
url="https://x.com",
doc_type="Email",
)
]
stats = push_to_zotero(
items,
store=store,
zotero_db=zot_path,
zotero_storage=str(tmp_path / "storage"),
)
assert stats["created"] >= 0
def test_pushes_rule(self, tmp_path):
zot_path = str(tmp_path / "z.sqlite")
con = create_db(zot_path)
con.close()
store = MagicMock()
store._con.return_value.execute.return_value.fetchall.return_value = []
items = [
Rule(
key="RULEKEY1",
title="PFS Rule",
fr_volume="88",
date_published="2023-01-01",
document_number="2023-1234",
)
]
stats = push_to_zotero(
items,
store=store,
zotero_db=zot_path,
zotero_storage=str(tmp_path / "storage"),
)
assert stats["created"] >= 0