File size: 1,249 Bytes
a3c590d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | from __future__ import annotations
from ragsolver.rag.retrieve import (
_informal_citation_label,
_informal_locator,
_mathlib_citation_label,
_mathlib_locator,
)
def test_mathlib_citation_label_and_locator():
row = {"decl_name": "Nat.Coprime", "module_path": "Mathlib.Data.Nat.GCD.Basic", "docs_url": "https://x/y#Nat.Coprime"}
assert _mathlib_citation_label(row) == "Nat.Coprime — Mathlib.Data.Nat.GCD.Basic"
locator = _mathlib_locator(row)
assert locator["decl_name"] == "Nat.Coprime"
assert locator["docs_url"].endswith("#Nat.Coprime")
def test_informal_citation_label_includes_item_and_page():
row = {"doc_id": "olimpiadas-2002", "item_number": 22, "page_start": 11}
assert _informal_citation_label(row) == "olimpiadas-2002, ítem 22, p. 11"
def test_informal_citation_label_degrades_gracefully_without_item_or_page():
row = {"doc_id": "paper-xyz"}
assert _informal_citation_label(row) == "paper-xyz"
def test_informal_locator_carries_figure_ids():
row = {"doc_id": "d1", "page_start": 5, "page_end": 5, "item_number": 3, "figure_ids": ["d1:fig:5:0"]}
locator = _informal_locator(row)
assert locator["figure_ids"] == ["d1:fig:5:0"]
assert locator["page_start"] == 5
|