Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

nit(ris): pin the three host edge shapes — truthy no-host, malformed URL, IPv6 PB line (#7355)

LearningCircuite3d2a2baf852
diff --git a/tests/exporters/test_ris_exporter.py b/tests/exporters/test_ris_exporter.py
index 937409ad6b..ff5c02df1d 100644
--- a/tests/exporters/test_ris_exporter.py
+++ b/tests/exporters/test_ris_exporter.py
@@ -232,6 +232,61 @@ URL: https://outofscope.example/o
assert "outofscope.example" not in exporter.export_to_ris(content)
+class TestRISExporterHostEdgeShapes:
+ """The three cheap edge shapes the #6838 review asked to pin: a
+ truthy no-host URL, a malformed URL, and an IPv6 authority's ``PB``
+ line. None of these break today (that review verified the shapes
+ behave); these pins keep a refactor of the publisher/host extraction
+ from regressing them silently."""
+
+ @pytest.fixture
+ def exporter(self):
+ """The legacy exporter that owns the Sources-block parser."""
+ from local_deep_research.text_optimization.citation_formatter import (
+ RISExporter,
+ )
+
+ return RISExporter()
+
+ @staticmethod
+ def _report(url: str) -> str:
+ return f"""# Research Report
+
+Text citing [1].
+
+## Sources
+
+[1] Edge Source Title
+URL: {url}
+"""
+
+ def test_truthy_no_host_url_exports_empty_pb_without_crashing(
+ self, exporter
+ ):
+ ris = exporter.export_to_ris(self._report("local:document"))
+ record = _ris_records(ris)["ref1"]
+ assert "UR - local:document" in record
+ # urlparse has no hostname for a bare scheme:path URL; the
+ # publisher falls back to the empty domain instead of raising.
+ assert "PB - \n" in record
+
+ def test_malformed_url_keeps_entry_without_pb_line(self, exporter):
+ ris = exporter.export_to_ris(self._report("http://[::1"))
+ record = _ris_records(ris)["ref1"]
+ # The unparseable authority drops the URL (and with it the PB
+ # line) but the record itself survives.
+ assert "TI - Edge Source Title" in record
+ assert "UR -" not in record
+ assert "PB -" not in record
+
+ def test_ipv6_host_pb_line_uses_bare_address(self, exporter):
+ ris = exporter.export_to_ris(self._report("https://[2001:DB8::1]/x"))
+ record = _ris_records(ris)["ref1"]
+ assert "UR - https://[2001:DB8::1]/x" in record
+ # urlparse strips the brackets and lowercases the address.
+ assert "PB - 2001:db8::1" in record
+
+
class TestRISExporterProperties:
"""Tests for RISExporter properties."""