Spaces:
Sleeping
Sleeping
| """Direct EU prep pure helpers — F6 surface (no I/O, no instrument_schema).""" | |
| from __future__ import annotations | |
| from core.strategy.direct_eu import ( | |
| CHECKLIST_ID, | |
| PATH_DIRECT_EU, | |
| attach_direct_eu_meta, | |
| direct_eu_prep_path_meta, | |
| horizon_prep_checklist, | |
| is_direct_eu_grant, | |
| never_maps_to_smart_pl, | |
| ) | |
| from core.strategy.recommend import recommend_strategy_paths | |
| def test_horizon_prep_checklist_nonempty(): | |
| cl = horizon_prep_checklist() | |
| assert len(cl) >= 4 | |
| assert any("SMART" in x or "smart" in x.lower() for x in cl) | |
| assert any("Funding" in x or "Tenders" in x for x in cl) | |
| def test_is_direct_eu_grant_horizon(): | |
| g = { | |
| "name": "Horizon Europe Cluster 4 call", | |
| "program": "Horizon Europe", | |
| "description": "RIA on digital twins", | |
| "tags": ["horizon"], | |
| } | |
| assert is_direct_eu_grant(g) is True | |
| def test_is_direct_eu_grant_eic_family(): | |
| assert is_direct_eu_grant({"family": "EIC", "name": "Accelerator"}) is True | |
| assert is_direct_eu_grant({"family": "HORIZON_PREP"}) is True | |
| assert is_direct_eu_grant({"direct_eu": True, "name": "x"}) is True | |
| assert is_direct_eu_grant({"family": "EUROGRANTY"}) is True | |
| def test_is_direct_eu_grant_not_smart_pl(): | |
| g = { | |
| "name": "Ścieżka SMART FENG.01 — moduł B+R", | |
| "program": "FENG", | |
| "description": "Ścieżka SMART cyfryzacja zazielenienie", | |
| } | |
| assert is_direct_eu_grant(g) is False | |
| def test_is_direct_eu_grant_empty_and_none(): | |
| assert is_direct_eu_grant(None) is False | |
| assert is_direct_eu_grant({}) is False | |
| assert is_direct_eu_grant("not-a-dict") is False # type: ignore[arg-type] | |
| def test_never_maps_to_smart_pl_invariant(): | |
| assert never_maps_to_smart_pl() is True | |
| assert never_maps_to_smart_pl({"family": "HORIZON"}) is True | |
| assert never_maps_to_smart_pl({"name": "Ścieżka SMART FENG.01"}) is False | |
| def test_attach_direct_eu_meta_on_path(): | |
| p = attach_direct_eu_meta({"id": PATH_DIRECT_EU, "score": 50, "reasons": ["x"]}) | |
| assert p.get("never_use_smart_modules") is True | |
| assert p.get("checklist") | |
| assert p.get("checklist_id") == CHECKLIST_ID | |
| assert p.get("notes") | |
| assert any("SMART" in n for n in p["notes"]) | |
| assert any("SMART" in r for r in p["reasons"]) | |
| def test_attach_direct_eu_meta_skips_other_paths(): | |
| raw = {"id": "national_feng", "score": 1} | |
| out = attach_direct_eu_meta(raw) | |
| assert "never_use_smart_modules" not in out | |
| assert "checklist_id" not in out | |
| def test_direct_eu_prep_path_meta_shape(): | |
| meta = direct_eu_prep_path_meta() | |
| assert meta["id"] == PATH_DIRECT_EU | |
| assert meta["never_use_smart_modules"] is True | |
| assert meta["checklist_id"] == "horizon_prep" | |
| assert len(meta["checklist"]) >= 4 | |
| def test_recommend_wires_direct_eu_meta(): | |
| r = recommend_strategy_paths(goal="deeptech horizon eic") | |
| eu = next(p for p in r["paths"] if p["id"] == PATH_DIRECT_EU) | |
| assert eu.get("never_use_smart_modules") is True | |
| assert eu.get("checklist_id") == CHECKLIST_ID | |
| assert eu.get("checklist") | |
| assert float(eu.get("score") or 0) > 40 | |