grantforge-api / backend /tests /test_compliance_checklist.py
GrantForge Bot
Deploy sha-565ad85979610064f6d1c18ab3b6404357d61073 — source build (no GHCR)
ce8f04a
Raw
History Blame Contribute Delete
2.11 kB
"""Testy checklist zgodności z regulaminem."""
from types import SimpleNamespace
from core.compliance.regulation_checklist import compliance_checklist
def _section(section_type: str, content: str = "Treść sekcji"):
return SimpleNamespace(section_type=section_type, content=content)
def test_checklist_passes_when_sections_match():
project = SimpleNamespace(
external_context={
"required_sections": ["Opis projektu", "Budżet"],
"required_attachments": [],
"regulation_section_titles": {
"opis_projektu": "Opis projektu",
"budzet": "Budżet",
},
}
)
sections = [
_section("opis_projektu", "Pełny opis projektu innowacyjnego."),
_section("budzet", "Szczegółowy budżet projektu."),
]
result = compliance_checklist(project, sections)
assert result.coverage_score >= 70
assert result.passed is True
assert not result.missing_sections
def test_checklist_detects_missing_sections():
project = SimpleNamespace(
external_context={
"required_sections": ["Opis projektu", "Budżet", "Harmonogram"],
"required_attachments": [],
}
)
sections = [_section("opis_projektu")]
result = compliance_checklist(project, sections)
assert len(result.missing_sections) >= 2
assert result.coverage_score < 70
assert result.passed is False
def test_checklist_skipped_for_legacy_project():
project = SimpleNamespace(external_context={"company_data": {"nip": "123"}})
result = compliance_checklist(project, [])
assert result.coverage_score == 100
assert result.passed is True
assert "pominięta" in result.recommendation.lower()
def test_checklist_missing_attachments():
project = SimpleNamespace(
external_context={
"required_sections": [],
"required_attachments": ["Kosztorys", "Oświadczenie MŚP"],
}
)
result = compliance_checklist(project, [])
assert len(result.missing_attachments) == 2
assert result.coverage_score == 0