Some checks failed
CI / skinny-install (aco) (push) Successful in 1m21s
CI / skinny-install (api) (push) Successful in 34s
CI / skinny-install (bcda) (push) Successful in 45s
CI / skinny-install (bib) (push) Successful in 5m59s
CI / skinny-install (bls) (push) Successful in 30s
CI / skinny-install (ccw) (push) Successful in 41s
CI / skinny-install (cli) (push) Successful in 46s
CI / skinny-install (cms) (push) Successful in 38s
CI / skinny-install (conf) (push) Successful in 33s
CI / skinny-install (opps) (push) Successful in 39s
CI / skinny-install (perf) (push) Successful in 41s
CI / skinny-install (pfs) (push) Successful in 44s
CI / skinny-install (rex) (push) Successful in 39s
Deploy / build-scan-report (push) Failing after 5m31s
CI / lint-test (push) Has been cancelled
210 lines
6.6 KiB
Python
210 lines
6.6 KiB
Python
"""Cover the last ~13 uncovered lines."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
|
|
class TestBibStoreDeletePincitesNoTable:
|
|
"""Lines 572-573: delete_pincites when pincites table doesn't exist."""
|
|
|
|
def test_returns_zero(self, tmp_path):
|
|
from bib.store import Store
|
|
|
|
store = Store(str(tmp_path / "test.sqlite"))
|
|
result = store.delete_pincites()
|
|
assert result == 0
|
|
|
|
|
|
class TestBibIomFetchIndexDedup:
|
|
"""Line 118: duplicate pub in index HTML → continue."""
|
|
|
|
def test_skips_duplicate_pub(self):
|
|
from bib.iom import fetch_index
|
|
|
|
html = """
|
|
<a href="/regulations-and-guidance/guidance/manuals/internet-only-manuals-ioms-items/cms018912">100-04</a>
|
|
<div><label>Title</label>Claims Processing Manual</div>
|
|
<a href="/regulations-and-guidance/guidance/manuals/internet-only-manuals-ioms-items/cms018913">100-04</a>
|
|
<div><label>Title</label>Claims Processing Manual Dup</div>
|
|
"""
|
|
client = MagicMock()
|
|
resp = MagicMock()
|
|
resp.text = html
|
|
resp.status_code = 200
|
|
client.get.return_value = resp
|
|
entries = fetch_index(client)
|
|
assert len(entries) == 1
|
|
|
|
|
|
class TestBibOigDownloadNoUrl:
|
|
"""Line 289: item with no URL → continue."""
|
|
|
|
def test_skips_no_url(self):
|
|
from bib.oig import download_attachments
|
|
|
|
store = MagicMock()
|
|
store._db_path = "/tmp/test.sqlite"
|
|
item_no_url = MagicMock()
|
|
item_no_url.url = ""
|
|
item_no_url.key = "K1"
|
|
item_with_url = MagicMock()
|
|
item_with_url.url = "https://oig.hhs.gov/doc.pdf"
|
|
item_with_url.key = "K2"
|
|
item_with_url.title = "Doc"
|
|
store.list_items.return_value = [item_no_url, item_with_url]
|
|
store._con.return_value.execute.return_value.fetchone.return_value = None
|
|
|
|
client = MagicMock()
|
|
resp = MagicMock()
|
|
resp.content = b"pdf"
|
|
resp.status_code = 200
|
|
client.get.return_value = resp
|
|
|
|
n = download_attachments(store, client)
|
|
assert n >= 1
|
|
|
|
|
|
class TestCliBibTranslateError:
|
|
"""Line 113: federal_register() raises → continue loop."""
|
|
|
|
@patch("bib.connect")
|
|
@patch("bib.federalregister.pfs_rules")
|
|
@patch("bib.translate.federal_register")
|
|
def test_skips_on_translate_error(self, mc_translate, mc_pfs, mc_connect):
|
|
from typer.testing import CliRunner
|
|
|
|
from cli.bib import app
|
|
|
|
doc1 = MagicMock()
|
|
doc1.publication_date = "2023-01-01"
|
|
doc1.type = "Proposed Rule"
|
|
doc1.document_number = "2023-111"
|
|
doc1.dockets = ["CMS-1"]
|
|
doc1.html_url = "https://example.com/1"
|
|
|
|
doc2 = MagicMock()
|
|
doc2.publication_date = "2023-02-01"
|
|
doc2.type = "Proposed Rule"
|
|
doc2.document_number = "2023-222"
|
|
doc2.dockets = ["CMS-2"]
|
|
doc2.html_url = "https://example.com/2"
|
|
|
|
mc_pfs.return_value = [doc1, doc2]
|
|
# First doc fails, second succeeds
|
|
rule = MagicMock()
|
|
mc_translate.side_effect = [ValueError("bad"), rule]
|
|
|
|
store = MagicMock()
|
|
mc_connect.return_value = store
|
|
|
|
runner = CliRunner()
|
|
result = runner.invoke(app, ["discover-pfs-rules"])
|
|
assert result.exit_code == 0
|
|
assert "skipped" in result.output
|
|
store.upsert.assert_called_once()
|
|
|
|
|
|
class TestCliBibPerDocketBreak:
|
|
"""Line 268: per_docket_limit reached → break."""
|
|
|
|
@patch("bib.connect")
|
|
@patch("bib.federalregister.pfs_rules")
|
|
@patch("bib.federalregister.split_docket_ids", return_value=["CMS-1"])
|
|
@patch("bib.translate.federal_register")
|
|
@patch("bib.regulations_gov.Client")
|
|
@patch("bib.regulations_gov.upsert_comment", return_value="KEY1")
|
|
def test_breaks_at_limit(
|
|
self, mc_upsert, mc_client_cls, mc_translate, mc_split, mc_pfs, mc_connect
|
|
):
|
|
from typer.testing import CliRunner
|
|
|
|
from cli.bib import app
|
|
|
|
store = MagicMock()
|
|
store._con.return_value = MagicMock()
|
|
mc_connect.return_value = store
|
|
|
|
doc = MagicMock()
|
|
doc.type = "Proposed Rule"
|
|
doc.publication_date = "2023-01-01"
|
|
doc.dockets = ["CMS-1"]
|
|
doc.html_url = "https://example.com"
|
|
mc_pfs.return_value = [doc]
|
|
mc_translate.return_value = MagicMock()
|
|
|
|
api = MagicMock()
|
|
api.__enter__ = MagicMock(return_value=api)
|
|
api.__exit__ = MagicMock(return_value=False)
|
|
mc_client_cls.return_value = api
|
|
api.resolve_docket.return_value = "CMS-2023-0001"
|
|
|
|
fr_doc = {
|
|
"id": "DOC1",
|
|
"attributes": {"objectId": "obj1", "commentEndDate": "2023-12-31"},
|
|
}
|
|
api.find_documents_in_docket.return_value = [fr_doc]
|
|
|
|
c1 = MagicMock(id="C1", attachment_count=0)
|
|
c2 = MagicMock(id="C2", attachment_count=0)
|
|
api.iter_comments.return_value = [c1, c2]
|
|
|
|
runner = CliRunner()
|
|
result = runner.invoke(app, ["fetch-pfs-comments", "--per-docket-limit", "1"])
|
|
assert result.exit_code == 0
|
|
|
|
|
|
class TestCliPrismaRunAllProxy:
|
|
"""Lines 480, 482: explicit proxy and vpn.active paths in run_all._proxy_cm."""
|
|
|
|
@patch("cli.prisma.subprocess.run")
|
|
@patch("zot.db.Db")
|
|
@patch("prisma.llm.make_provider")
|
|
@patch("prisma.project.load")
|
|
@patch("prisma.screen.run", return_value={"screened": 0})
|
|
@patch("prisma.fetch.run", return_value={"fetched": 0})
|
|
@patch("prisma.eligibility.run", return_value={"eligible": 0})
|
|
@patch("prisma.extract.run", return_value={"extracted": 0})
|
|
@patch("prisma.flow.count")
|
|
@patch("prisma.flow.text_summary", return_value="OK")
|
|
@patch.dict("os.environ", {"PRISMA_FETCH_PROXY": "socks5://explicit:1080"})
|
|
def test_explicit_proxy(
|
|
self,
|
|
mc_summary,
|
|
mc_count,
|
|
mc_extract,
|
|
mc_elig,
|
|
mc_fetch,
|
|
mc_screen,
|
|
mc_load,
|
|
mc_prov,
|
|
mc_db_cls,
|
|
mc_sub,
|
|
):
|
|
from typer.testing import CliRunner
|
|
|
|
from cli.prisma import app
|
|
|
|
db = MagicMock()
|
|
db.__enter__ = MagicMock(return_value=db)
|
|
db.__exit__ = MagicMock(return_value=False)
|
|
mc_db_cls.return_value = db
|
|
mc_prov.return_value = MagicMock()
|
|
mc_load.return_value = MagicMock()
|
|
mc_count.return_value = MagicMock()
|
|
|
|
runner = CliRunner()
|
|
result = runner.invoke(app, ["run", "test-proj", "--no-hold"])
|
|
assert result.exit_code == 0
|
|
|
|
|
|
class TestRecPricersSingleCf:
|
|
"""Line 131: single conv_factor value."""
|
|
|
|
def test_single_cf(self):
|
|
from rec.pricers.pfs import PfsPricer
|
|
|
|
pricer = PfsPricer()
|
|
assert hasattr(pricer, "compare_cols")
|
|
assert hasattr(pricer, "join_keys")
|