fix: require a DIFFERENT recipe component to cover a per-code gap
.recipe_coverage()'s covered_years were computed once per recipe as a
union across ALL of its components (aggregate rows included), without
excluding the component currently being tested for a gap. So a code
whose only representation in a year was its own wide-era aggregate row
satisfied its own "covered" check -- self-coverage, not the "other
components" review-doc 0.3's criterion actually specifies ("...has no
rows ... but other components do").
.recipe_coverage() now returns (recipe_id, component_code, year)
triples instead of collapsing across components, and
.recipe_component_gapped() excludes the component under test before
checking coverage, so a gap only fires when a genuinely different
sibling component has data in that year.
Adds the boundary test this gap in coverage let slip through untested:
Broward FY2011 alone, where E05/F05/G05 each report solely as their own
wide-era aggregate row and E04/F04/G04 don't exist as codes before 2012
corpus-wide, so none of the three Corrections recipes have any OTHER
component to cover them -- must produce zero suggestions. The existing
2011-2012 combined test still passes, now firing because of the 2012
E05-gapped/E04-covers pair rather than 2011's self-coverage. Updates the
header comment to state the other-component requirement explicitly.
This commit is contained in:
@@ -203,6 +203,25 @@ test_that("signposting suggests corrections_combined across the 2011->2012 gap",
|
||||
expect_equal(hit$available_years, c(1967L, 2023L))
|
||||
})
|
||||
|
||||
test_that("per-code gap does NOT fire when a code's only coverage is its own aggregate row (self-coverage is not \"other components\")", {
|
||||
skip_if_no_corpus()
|
||||
# Broward, FY2011 ONLY (isolating the 2011 half of the query above): E05,
|
||||
# F05, and G05 each report SOLELY as a wide-era AGGREGATE row that year
|
||||
# (216088, 1453, 270 respectively); E04/F04/G04 -- their modern-only
|
||||
# siblings -- don't exist as codes at all before 2012, corpus-wide (zero
|
||||
# rows for any government). Each component's own aggregate row would
|
||||
# trivially satisfy a same-component "covered" check, but review-doc
|
||||
# § 0.3's criterion is explicit that a gap must be covered by "OTHER
|
||||
# components", not the gapped component's own aggregate form. With no
|
||||
# OTHER component present for any of the three Corrections recipes in
|
||||
# 2011, none of them should fire -- this is what the combined
|
||||
# 2011-2012 test above actually relies on 2012 (E05 gapped, E04 -- a
|
||||
# genuinely different component -- covers) to fire, not 2011.
|
||||
r <- cog_spending("121011212191", years = 2011L, category = "Corrections")
|
||||
prov <- attr(r, "provenance")
|
||||
expect_length(prov$suggestions, 0L)
|
||||
})
|
||||
|
||||
test_that("per-code gap fires even when a sibling code masks the whole-result check (Cleburne County, FY2012)", {
|
||||
skip_if_no_corpus()
|
||||
# Cleburne County, AL (canonical_govid 011029122489), FY2012: E04 ($854)
|
||||
|
||||
Reference in New Issue
Block a user