File size: 2,866 Bytes
ce8f04a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"""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