Spaces:
Running
Running
| """Tests for context bus, zero-match diagnostics, export headings, gap analyzer.""" | |
| from core.context.context_bus import filter_clarifying_questions, propagate_to_gsd_blackboard | |
| from core.match.zero_result_diagnostics import diagnose_zero_match | |
| from utils.export_documents import localize_markdown_headings | |
| from agents.gap_analyzer import build_clarifying_questions | |
| def test_filter_clarifying_questions_skips_pkd_when_pkd_codes_present(): | |
| company = {"pkd_codes": ["62.01.Z"], "nip": "1234567890"} | |
| questions = [ | |
| "Podaj główny kod PKD działalności objętej projektem.", | |
| "W jakim województwie realizowany będzie projekt?", | |
| ] | |
| filtered = filter_clarifying_questions(questions, company, []) | |
| assert all("PKD" not in q for q in filtered) | |
| assert len(filtered) == 1 | |
| def test_propagate_to_gsd_blackboard_merges_company_data(): | |
| bb = {"company_data": {"name": "ACME"}} | |
| external = { | |
| "company_data": {"nip": "5250000000", "voivodeship": "mazowieckie"}, | |
| "data_gaps": ["Brak opisu celu projektu."], | |
| } | |
| out = propagate_to_gsd_blackboard(bb, external) | |
| assert out["company_data"]["name"] == "ACME" | |
| assert out["company_data"]["nip"] == "5250000000" | |
| assert out["context_bus_version"] | |
| def test_diagnose_zero_match_no_catalog(): | |
| diag = diagnose_zero_match({}, "dotacja", 0, 0, []) | |
| assert diag["reason_code"] == "no_catalog" | |
| assert diag["user_message"] | |
| def test_localize_markdown_headings_budget(): | |
| md = "## Budget\n\nTreść" | |
| out = localize_markdown_headings(md, lang="pl") | |
| assert "## Budżet" in out | |
| def test_gap_analyzer_build_clarifying_questions_filters_known_fields(): | |
| profile = { | |
| "nip": "1234567890", | |
| "pkd_codes": ["62.01.Z"], | |
| "voivodeship": "mazowieckie", | |
| "industry": "Rozwój oprogramowania SaaS dla MŚP z planem inwestycji", | |
| } | |
| gaps = [ | |
| "Brak kodów PKD.", | |
| "Brak profilu firmy (NIP/GUS).", | |
| "Brak województwa.", | |
| ] | |
| qs = build_clarifying_questions(gaps, profile) | |
| joined = " ".join(qs).lower() | |
| assert "pkd" not in joined | |
| assert "nip" not in joined | |
| assert "wojew" not in joined | |