fix: close remaining ingestion review gaps
This commit is contained in:
@@ -650,6 +650,76 @@ async def test_queued_parser_skip_stays_blocked_with_actionable_reason(
|
||||
assert gap.reason == "parser_unusable"
|
||||
|
||||
|
||||
async def test_new_parser_skip_gets_grace_then_enters_retry_queue(
|
||||
engine, monkeypatch
|
||||
):
|
||||
from app.services.sec_facts_parser import ParseResult
|
||||
|
||||
factory = _factory(engine)
|
||||
await _seed(factory, ["AAPL"])
|
||||
backfill = FakeSecClient(
|
||||
tickers={"AAPL": 320193},
|
||||
companyfacts={320193: _companyfacts([CF_K, CF_Q1], [SH_K, SH_Q1])},
|
||||
submissions={320193: _submissions(SUB_FILINGS)},
|
||||
latest_index=date(2026, 1, 31),
|
||||
)
|
||||
await run_import(_importer(backfill), engine=engine)
|
||||
|
||||
bad_fact = _rev(
|
||||
"2025-09-28", "2026-03-28", 254940, 2026, "Q2", "NEWBAD"
|
||||
)
|
||||
bad_share = _shares("2026-04-17", 14687, "NEWBAD", 2026, "Q2")
|
||||
client = FakeSecClient(
|
||||
tickers={"AAPL": 320193},
|
||||
companyfacts={
|
||||
320193: _companyfacts(
|
||||
[CF_K, CF_Q1, bad_fact], [SH_K, SH_Q1, bad_share]
|
||||
)
|
||||
},
|
||||
submissions={320193: _submissions(SUB_FILINGS + [
|
||||
_filing(
|
||||
"NEWBAD",
|
||||
"10-Q",
|
||||
"2026-03-28",
|
||||
"2026-05-01",
|
||||
"2026-05-01T10:01:00.000Z",
|
||||
)
|
||||
])},
|
||||
latest_index=date(2026, 5, 2),
|
||||
daily={
|
||||
date(2026, 5, 1): [{
|
||||
"form": "10-Q",
|
||||
"cik": 320193,
|
||||
"accession": "NEWBAD",
|
||||
}]
|
||||
},
|
||||
)
|
||||
|
||||
def skip_parse(*args, **kwargs):
|
||||
return ParseResult(skipped_filings=[{
|
||||
"accession": "NEWBAD",
|
||||
"reason": "unparseable",
|
||||
}])
|
||||
|
||||
monkeypatch.setattr("app.services.sec_facts_parser.parse_snapshots", skip_parse)
|
||||
|
||||
young = await run_import(
|
||||
_importer(client, today=date(2026, 5, 3)), engine=engine
|
||||
)
|
||||
assert young.status == STATUS_DEFERRED
|
||||
assert "parser_unusable" in (young.error_details or "")
|
||||
assert await _count(factory, SecFilingGap) == 0
|
||||
|
||||
aged = await run_import(
|
||||
_importer(client, today=date(2026, 5, 5)), engine=engine
|
||||
)
|
||||
assert aged.status == STATUS_PROMOTED
|
||||
async with factory() as db:
|
||||
gap = (await db.execute(select(SecFilingGap))).scalar_one()
|
||||
assert gap.accession == "NEWBAD"
|
||||
assert gap.reason == "parser_unusable"
|
||||
|
||||
|
||||
async def test_validation_caps_details_but_keeps_complete_blocked_cik_set():
|
||||
importer = SecFundamentalsImporter(today=date(2026, 5, 20))
|
||||
importer._latest_index_date = date(2026, 5, 19)
|
||||
|
||||
Reference in New Issue
Block a user