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: add boilerplate-absent assertions to extraction tests (#3407)

LearningCircuit7375bb09283a
diff --git a/tests/research_library/downloaders/test_html_downloader.py b/tests/research_library/downloaders/test_html_downloader.py
index f5b32d073b..1e2f92b15e 100644
--- a/tests/research_library/downloaders/test_html_downloader.py
+++ b/tests/research_library/downloaders/test_html_downloader.py
@@ -136,6 +136,9 @@ class TestExtractContent:
result = dl._extract_content(html, "http://example.com")
assert result is not None
assert LONG_PARA in result["content"]
+ # Verify boilerplate is actually removed, not just that content is present
+ assert "Copyright 2024" not in result["content"]
+ assert "Sidebar widget" not in result["content"]
def test_removes_elements_matching_class_patterns(self, dl):
"""Extraction pipeline filters sidebar/cookie boilerplate."""
@@ -149,6 +152,10 @@ class TestExtractContent:
result = dl._extract_content(html, "http://example.com")
assert result is not None
assert LONG_PARA in result["content"]
+ # Verify boilerplate is actually removed
+ assert "Sidebar stuff" not in result["content"]
+ assert "Accept cookies" not in result["content"]
+ assert "Copyright 2024" not in result["content"]
def test_removes_elements_matching_id_patterns(self, dl):
"""Extraction pipeline filters sidebar boilerplate matched by element IDs."""
@@ -161,6 +168,9 @@ class TestExtractContent:
result = dl._extract_content(html, "http://example.com")
assert result is not None
assert LONG_PARA in result["content"]
+ # Verify boilerplate is actually removed
+ assert "Sidebar by ID" not in result["content"]
+ assert "Copyright 2024" not in result["content"]
# --- Content area detection ---
@@ -263,6 +273,51 @@ class TestExtractContent:
assert result is not None
assert long_text in result["content"]
+ def test_realistic_page_boilerplate_removal(self, dl):
+ """Pipeline removes boilerplate from a realistic page with multiple noise sections."""
+ article_text = (
+ "Scientists at CERN have discovered a new particle that could "
+ "revolutionize our understanding of quantum physics. The finding, "
+ "published in Nature, describes a subatomic interaction that was "
+ "previously thought to be impossible under the Standard Model."
+ )
+ html = make_html(
+ '<header><div class="top-bar">'
+ "<span>Subscribe to our newsletter for daily updates</span>"
+ "</div></header>"
+ '<nav class="main-nav">'
+ '<a href="/">Home</a><a href="/science">Science</a>'
+ '<a href="/tech">Tech</a><a href="/about">About Us</a>'
+ "</nav>"
+ f"<article><h1>New Particle Discovery</h1><p>{article_text}</p></article>"
+ '<div class="cookie-consent">'
+ "<p>We use cookies to improve your experience. Accept all cookies.</p>"
+ "</div>"
+ '<aside class="sidebar">'
+ "<h3>Trending Articles</h3>"
+ "<ul><li>Top 10 Physics Breakthroughs</li>"
+ "<li>What is Dark Matter?</li></ul>"
+ "</aside>"
+ "<footer>"
+ "<p>Copyright 2025 Science Daily. Privacy Policy. Terms of Service.</p>"
+ "<p>Contact us at [email protected]</p>"
+ "</footer>"
+ )
+ result = dl._extract_content(html, "http://example.com")
+ assert result is not None
+ content = result["content"]
+
+ # Main article content must be present
+ assert "CERN" in content
+ assert "quantum physics" in content
+
+ # Boilerplate must be absent
+ assert "Subscribe to our newsletter" not in content
+ assert "Accept all cookies" not in content
+ assert "Privacy Policy" not in content
+ assert "[email protected]" not in content
+ assert "Trending Articles" not in content
+
# ===================================================================
# Extractor configuration