Spaces:
Running
Running
| """Testy scalania odpowiedzi HITL z profilem firmy.""" | |
| from core.registry_enrichment import ( | |
| _analyze_gaps, | |
| _parse_financials_from_text, | |
| apply_clarifications_to_profile, | |
| filter_answered_questions, | |
| gaps_to_hitl_questions, | |
| ) | |
| def test_parse_financials_from_polish_answer(): | |
| fin = _parse_financials_from_text("Przychód roczny 2 mln PLN, 5 pracowników FTE") | |
| assert fin.get("revenue") == 2_000_000 | |
| assert fin.get("employment") == 5 | |
| def test_apply_clarifications_clears_financial_gap(): | |
| company = {"name": "Test Sp. z o.o.", "pkd": ["62.01.Z"], "address": "Warszawa"} | |
| answers = [ | |
| { | |
| "question": "Podaj przybliżony przychód roczny i liczbę pracowników (FTE).", | |
| "answer": "Roczny przychód ok. 1,5 mln PLN, zatrudnienie 8 FTE", | |
| } | |
| ] | |
| merged = apply_clarifications_to_profile(company, "Opis projektu inwestycyjnego", answers) | |
| gaps = _analyze_gaps(merged, "Opis projektu inwestycyjnego") | |
| questions = gaps_to_hitl_questions(gaps) | |
| assert merged["financials"]["revenue"] == 1_500_000 | |
| assert merged["financials"]["employment"] == 8 | |
| assert not any("finansowych" in g for g in gaps) | |
| assert "Podaj przybliżony przychód roczny i liczbę pracowników (FTE)." not in questions | |
| def test_filter_answered_questions(): | |
| questions = [ | |
| "Podaj przybliżony przychód roczny i liczbę pracowników (FTE).", | |
| "Czy firma otrzymała pomoc publiczną?", | |
| ] | |
| answers = [ | |
| { | |
| "question": "Podaj przybliżony przychód roczny i liczbę pracowników (FTE).", | |
| "answer": "2 mln, 3 FTE", | |
| } | |
| ] | |
| filtered = filter_answered_questions(questions, answers) | |
| assert filtered == ["Czy firma otrzymała pomoc publiczną?"] | |