Spaces:
Running
Running
| """Testy poprawek audytu i eksportu (timeout, fallback, markdown).""" | |
| def test_deterministic_audit_fallback_detects_pkd(): | |
| from endpoints.projects import _deterministic_audit_fallback | |
| content = "Firma XYZ\nZweryfikowano przez GUS (Brak PKD)\n" + ("Treść wniosku. " * 80) | |
| result = _deterministic_audit_fallback(content, "SMART") | |
| assert result["status"] == "completed" | |
| assert result["overall_score"] < 70 | |
| assert any("PKD" in i.get("message", "") for i in result["issues"]) | |
| def test_build_markdown_from_sections_polish_titles(): | |
| from types import SimpleNamespace | |
| from core.project_markdown import build_markdown_from_sections | |
| project = SimpleNamespace( | |
| external_context={"company_data": {"name": "Test Sp. z o.o."}}, | |
| program_type="SMART", | |
| ) | |
| sections = [ | |
| SimpleNamespace( | |
| section_type="project_summary", | |
| title=None, | |
| content="Streszczenie projektu testowego.", | |
| ), | |
| SimpleNamespace( | |
| section_type="budget", | |
| title=None, | |
| content="Budżet projektu wynosi 500 000 PLN.", | |
| ), | |
| ] | |
| md = build_markdown_from_sections(project, sections, {}) | |
| assert "Streszczenie Projektu" in md | |
| assert "Budżet i kwalifikowalność kosztów" in md or "Budżet" in md | |
| assert "FINAL_DOCUMENT" not in md | |
| def test_normalize_stale_pending_audit(): | |
| from datetime import datetime, timezone, timedelta | |
| from endpoints.projects import _normalize_audit_payload | |
| stale = { | |
| "status": "pending", | |
| "pending_at": (datetime.now(timezone.utc) - timedelta(minutes=20)).isoformat(), | |
| } | |
| normalized = _normalize_audit_payload(stale) | |
| assert normalized["status"] == "error" | |