Files
stack/tests/prisma/test_ingest_deep.py
kert 917382c885
Some checks failed
CI / lint-test (push) Failing after 26s
CI / skinny-install (api) (push) Successful in 44s
CI / skinny-install (aco) (push) Successful in 1m17s
CI / skinny-install (bcda) (push) Successful in 47s
CI / skinny-install (bib) (push) Successful in 47s
CI / skinny-install (bls) (push) Successful in 32s
CI / skinny-install (ccw) (push) Successful in 29s
CI / skinny-install (cms) (push) Successful in 37s
CI / skinny-install (cli) (push) Successful in 46s
CI / skinny-install (opps) (push) Successful in 29s
CI / skinny-install (conf) (push) Successful in 43s
CI / skinny-install (perf) (push) Successful in 43s
CI / skinny-install (pfs) (push) Successful in 41s
CI / skinny-install (rex) (push) Successful in 38s
Deploy / build-scan-report (push) Failing after 5m12s
Package Supply Chain / pkg-supply-chain (push) Failing after 42s
test: coverage push 95.23% — deep tests for 30+ modules, tracks #353
308 new lines covered this batch (2,605→2,297 missed). Import + smoke
tests replaced with exercising tests for iom, oig, sync, flow, llm,
droplet, cloudflare, postmark, resend, export, project, ingest, plus
CLI --help coverage for all bib/prisma/zot/rec commands.

Remaining gap to 99%: 1,816 lines across cli/, mail/droplet, prisma/vpn,
bib/regulations_gov, prisma/fetch. All require mocked CliRunner or
httpx/pydo/subprocess exercising tests. Work continues — this commit
preserves progress.
2026-04-17 14:14:18 -04:00

55 lines
1.6 KiB
Python

"""Deep tests for prisma.ingest."""
from __future__ import annotations
import sqlite3
from prisma.ingest import (
_add_tags,
_delete_tags_with_prefix,
_html_escape,
)
from tests.zot.test_db import ZOTERO_SCHEMA, _seed_schema_maps
from zot.db import TYPE_MAP, Db
class TestHtmlEscape:
def test_escapes(self):
assert "&lt;" in _html_escape("<b>")
assert "&amp;" in _html_escape("&")
class TestDeleteTagsWithPrefix:
def test_deletes(self, tmp_path):
path = str(tmp_path / "z.sqlite")
con = sqlite3.connect(path)
con.executescript(ZOTERO_SCHEMA)
_seed_schema_maps(con)
con.commit()
con.close()
with Db(path) as db:
iid = db.create_item(TYPE_MAP["document"])
db.sync_tags(iid, ["screen:include", "screen:reason:good", "other:tag"])
db.commit()
_delete_tags_with_prefix(db, iid, "screen:")
tags = db.get_tags(iid)
assert not any(t.startswith("screen:") for t in tags)
assert "other:tag" in tags
class TestAddTags:
def test_adds(self, tmp_path):
path = str(tmp_path / "z.sqlite")
con = sqlite3.connect(path)
con.executescript(ZOTERO_SCHEMA)
_seed_schema_maps(con)
con.commit()
con.close()
with Db(path) as db:
iid = db.create_item(TYPE_MAP["document"])
_add_tags(db, iid, ["new:tag1", "new:tag2"])
db.commit()
tags = db.get_tags(iid)
assert "new:tag1" in tags
assert "new:tag2" in tags