Files
stack/tests/bib/test_backfill_sealed.py

45 lines
1.3 KiB
Python

from __future__ import annotations
from unittest.mock import MagicMock
from bib.dockets import Docket
from bib.regulations_gov import backfill_details, backfill_from_mirror
from bib.store import Store
D = "CMS-2019-0111"
def _sealed_store() -> Store:
s = Store(":memory:", storage_dir="/tmp/nope")
s.docket_upsert(
Docket(id=D, sealed_at="2020-06-01T00:00:00Z", seal_reason="manual")
)
return s
def test_api_backfill_skips_sealed_without_calls():
s = _sealed_store()
api = MagicMock()
stats = backfill_details(s, api, docket=D)
assert stats["skipped_sealed"] == 1 and stats["seen"] == 0
api.get_comment_detail.assert_not_called()
def test_mirror_backfill_skips_sealed_without_listing():
s = _sealed_store()
m = MagicMock()
stats = backfill_from_mirror(s, m, docket=D)
assert stats["skipped_sealed"] == 1 and stats["seen"] == 0
m.comment_ids.assert_not_called()
m.attachment_keys.assert_not_called()
def test_force_runs_sealed_mirror_backfill():
s = _sealed_store()
m = MagicMock()
m.comment_ids.return_value = []
m.attachment_keys.return_value = {}
stats = backfill_from_mirror(s, m, docket=D, force=True)
assert "skipped_sealed" not in stats
m.comment_ids.assert_called_once_with(D)