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.

test(pdf_service): patch validate_url in accept-control cell so no live DNS is resolved (#6799)

LearningCircuitaf021e38615c
diff --git a/tests/web_services/test_pdf_service.py b/tests/web_services/test_pdf_service.py
index eb87a01788..6572f2d04d 100644
--- a/tests/web_services/test_pdf_service.py
+++ b/tests/web_services/test_pdf_service.py
@@ -514,7 +514,18 @@ class TestRefusedResourceDoesNotAbortTheExport:
def test_an_allowed_url_is_fetched_normally_by_the_skipping_fetcher(self):
"""And the accept control for it: the retry fetcher is not a blanket
"return nothing", or the retried render would silently drop every
- legitimate resource the report references."""
+ legitimate resource the report references.
+
+ ``validate_url`` is patched (not just ``_URL_FETCHER``) so the cell
+ performs no network I/O: the real validator resolves hostnames via
+ ``socket.getaddrinfo``, and an offline/sandboxed runner used to
+ turn that lookup into a misleading ``is payload`` failure through
+ the fetcher's blanket except (#6589). WeasyPrint is loaded first:
+ a cold ``_ensure_weasyprint`` inside the call would replace the
+ patched ``_URL_FETCHER`` with the real one, so the cell only passed
+ when an earlier test had loaded it. The raising ``getaddrinfo``
+ guard makes any real lookup fail the cell deterministically instead of reaching out.
+ """
from local_deep_research.web.services import pdf_service
payload = {"string": b"body", "mime_type": "text/css"}
@@ -523,8 +534,17 @@ class TestRefusedResourceDoesNotAbortTheExport:
def fetch(self, url):
return payload
- with patch.object(pdf_service, "_URL_FETCHER", _Fetcher()):
+ pdf_service._ensure_weasyprint() # populate the lazy _URL_FETCHER
+
+ def _no_resolution(*_args, **_kwargs):
+ raise OSError("getaddrinfo disabled: no network in unit tests")
+
+ with (
+ patch.object(pdf_service, "validate_url", return_value=True),
+ patch.object(pdf_service, "_URL_FETCHER", _Fetcher()),
+ patch("socket.getaddrinfo", side_effect=_no_resolution),
+ ):
assert (
pdf_service._skipping_url_fetcher("https://example.com/x.css")
is payload
- )
+ ), "an allowed URL must reach the (patched) module URL fetcher"