"""Testy wielodokumentowych regulaminów i rankingu URL.""" from __future__ import annotations from core.grants.regulation_url_quality import ( collect_all_regulation_urls, infer_doc_role, rank_regulation_urls, ) from core.grants.wyszukiwarka_mapper import map_wyszukiwarka_entry from .test_parp_regulation_discovery import EUROGRANTY_ENTRY, RWP_PDF def test_rank_regulation_urls_returns_multiple_valid_docs(): urls = rank_regulation_urls( [ EUROGRANTY_ENTRY["link_regulamin"], EUROGRANTY_ENTRY["link_ogloszenie"], RWP_PDF, EUROGRANTY_ENTRY["dokumenty_wniosku"], ], max_urls=5, ) assert RWP_PDF in urls assert EUROGRANTY_ENTRY["link_ogloszenie"] in urls assert EUROGRANTY_ENTRY["link_regulamin"] not in urls assert len(urls) >= 2 def test_collect_all_regulation_urls_from_entry(): urls = collect_all_regulation_urls(EUROGRANTY_ENTRY, max_urls=6) assert urls[0] == RWP_PDF or urls[0] == EUROGRANTY_ENTRY["link_ogloszenie"] assert len(urls) >= 2 def test_infer_doc_role_labels(): assert infer_doc_role(RWP_PDF) == "rwp" assert infer_doc_role(EUROGRANTY_ENTRY["link_ogloszenie"]) == "ogloszenie" def test_wyszukiwarka_mapper_includes_regulation_urls_list(): mapped = map_wyszukiwarka_entry(EUROGRANTY_ENTRY) assert mapped is not None assert isinstance(mapped.get("regulation_urls"), list) assert len(mapped["regulation_urls"]) >= 2 assert mapped["regulation_url"] in mapped["regulation_urls"]