grantforge-api / backend /tests /test_api_instrument_plan_12m_surface.py
GrantForge Bot
Deploy sha-565ad85979610064f6d1c18ab3b6404357d61073 — source build (no GHCR)
ce8f04a
Raw
History Blame Contribute Delete
2.87 kB
"""Structural + unit: nabory instrument-stats / dossier-stats expose plan_12m §13."""
from __future__ import annotations
import inspect
from types import SimpleNamespace
from unittest.mock import MagicMock, patch
import pytest
from core.projects.instrument_ops import build_plan_12m_metrics_snapshot
from endpoints import grants_nabory_enhanced as nabory_mod
def _find_route(path_suffix: str):
# nabory routes are registered via register function — import handlers if exported
# Fall back to source inspection of module
return None
def test_nabory_module_wires_plan_12m_and_dossier():
src = inspect.getsource(nabory_mod)
assert "build_plan_12m_metrics_snapshot" in src
assert "compute_instrument_project_metrics" in src
assert "compute_readiness_distribution" in src
assert "dossier-stats" in src or "dossier_stats" in src
assert "instrument-stats" in src or "instrument_stats" in src
assert "plan_12m" in src
def test_plan_12m_section_13_status_all_pass_when_seeded_catalog():
snap = build_plan_12m_metrics_snapshot(
project_metrics={
"total_projects_scanned": 10,
"pct_with_schema": 80.0,
"pct_ready_to_generate": 50.0,
"pct_structure_only": 10.0,
"eligibility_strategy_coverage": {
"with_eligibility_snapshot": 9,
"with_strategy_path": 5,
"with_de_minimis_source": 7,
"with_msp_confidence_ge_0_7": 6,
"projects_scanned_for_firm_metrics": 10,
},
},
catalog_stats={
"dossier_readiness": {
"sample_size": 10,
"total": 10,
"pct_not_blind": 70.0,
"meets_dod_70_not_blind": True,
}
},
)
assert snap["section_13_status"]["3_gold_families_ge_12"] == "PASS"
assert snap["section_13_status"]["5_dossier_not_blind_70"] == "PASS"
assert snap["section_13_status"]["4_tax_paths"] == "PASS"
assert snap["section_13_status"]["6_direct_eu"] == "PASS"
assert snap["section_13_status"]["8_bk2021_surface"] == "PASS"
assert snap["dod_product_pass"] is True
assert snap["dod_all_pass"] is True
assert snap["sla_claim_allowed"] is False
assert snap["version"] >= 2
def test_plan_12m_section_13_5_blocker_when_empty_catalog():
snap = build_plan_12m_metrics_snapshot(
catalog_stats={
"dossier_readiness": {
"sample_size": 0,
"total": 0,
"pct_not_blind": None,
"meets_dod_70_not_blind": False,
}
}
)
assert snap["section_13_status"]["5_dossier_not_blind_70"] == "external-blocker"
assert snap["dod_product_pass"] is False
assert snap["dod_all_pass"] is True # blocker allowed for dod_all_pass