grantforge-api / backend /tests /test_match_program_service.py
GrantForge Bot
Deploy sha-3d4ebe3261a5907e50617c6c64d42c59bd3d4877 — source build (no GHCR)
61d1e19
Raw
History Blame Contribute Delete
1.75 kB
"""Testy dopasowania programów — rule-based bez LLM."""
import pytest
from core.grants.recommendations import score_grant_for_company
from core.match.match_program_service import _build_company_profile, _program_type_from_grant
def test_build_company_profile_adds_clarifying_when_no_description():
company, gaps, questions = _build_company_profile(
"1234567890",
"",
{"company_data": {"name": "Test Sp. z o.o.", "pkd": ["62.01.Z"]}, "gaps": []},
)
assert company["name"] == "Test Sp. z o.o."
assert any("opisu" in g.lower() or "cel" in g.lower() for g in gaps)
assert len(questions) >= 1
def test_program_type_never_unknown():
grant = {
"zrodlo": "PARP — Nabory",
"operator": "PARP",
"source": "wyszukiwarka:PARP — Nabory",
}
assert _program_type_from_grant(grant) != "UNKNOWN"
assert "PARP" in _program_type_from_grant(grant)
def test_score_grant_returns_real_name():
company = {
"size": "mikro",
"region": "mazowieckie",
"pkd": ["62.01.Z"],
"entity_type": "przedsiębiorca",
}
grant = {
"id": "test-1",
"name": "Program rozwoju IT dla MŚP",
"status": "active",
"eligible_regions": ["mazowieckie", "cała Polska"],
"eligible_company_sizes": ["mikro", "małe"],
"beneficiary_tags": ["mśp", "przedsiębiorca"],
"operator": "PARP",
"zrodlo": "PARP — Nabory",
"description": "Wsparcie cyfryzacji firm IT",
"eligible_pkd": ["62"],
}
rec = score_grant_for_company(grant, company)
assert rec["grant_name"] == "Program rozwoju IT dla MŚP"
assert rec["grant_id"] == "test-1"
assert rec["relevance_score"] >= 40