Build & Deploy ResearchOwl / build-and-push (push) Successful in 7s
Nuevo _seed_news: registra el feed de Bing News como fuente rss y _extract_rss (F3) siembra sus entries — sin lógica de parseo duplicada. _unwrap_news_link extrae la URL real del publisher del ?url= de apiclick.aspx. Bing y no Google News como pedía el plan: verificado en vivo que los links de news.google.com/rss/articles/ acaban en muro de consent (UE) y el id AU_yqL solo se resuelve vía batchexecute interno — habría sembrado URLs muertas. Los de Bing llevan la URL real en texto plano. Flag off por defecto: se activará deliberadamente vía deployment. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
51 lines
2.3 KiB
Python
51 lines
2.3 KiB
Python
import pytest
|
|
from src.scraper.exhaustive import detect_source_type, is_blacklisted, normalize_url
|
|
from src.processor.processor import simple_chunk
|
|
|
|
|
|
def test_detect_source_type():
|
|
assert detect_source_type("https://youtube.com/watch?v=dQw4w9WgXcY") == "youtube"
|
|
assert detect_source_type("https://reddit.com/r/test/comments/abc") == "reddit"
|
|
assert detect_source_type("https://en.wikipedia.org/wiki/Roswell") == "wikipedia"
|
|
assert detect_source_type("https://example.com/doc.pdf") == "pdf"
|
|
assert detect_source_type("https://example.com/article") == "web"
|
|
|
|
|
|
def test_detect_source_type_rss():
|
|
assert detect_source_type("https://thedebrief.org/feed/") == "rss"
|
|
assert detect_source_type("https://example.com/rss") == "rss"
|
|
assert detect_source_type("https://example.com/feeds/all.atom.xml") == "rss"
|
|
assert detect_source_type("https://www.liberationtimes.com/?format=rss") == "rss"
|
|
# Falsos positivos del substring viejo: no son feeds.
|
|
assert detect_source_type("https://example.com/feedback") == "web"
|
|
assert detect_source_type("https://example.com/atomic-theory") == "web"
|
|
|
|
|
|
def test_is_blacklisted():
|
|
assert is_blacklisted("https://facebook.com/something") == True
|
|
assert is_blacklisted("https://en.wikipedia.org/wiki/Test") == False
|
|
|
|
|
|
def test_normalize_url():
|
|
assert normalize_url("https://example.com/page#section") == "https://example.com/page"
|
|
assert normalize_url("https://example.com/page/") == "https://example.com/page"
|
|
|
|
|
|
def test_simple_chunk():
|
|
text = "\n\n".join([f"Paragraph {i} with some content here." for i in range(50)])
|
|
chunks = simple_chunk(text, chunk_size=100, overlap=20)
|
|
assert len(chunks) > 1
|
|
assert all(isinstance(c, str) for c in chunks)
|
|
|
|
|
|
def test_unwrap_news_link():
|
|
from src.scraper.exhaustive import _unwrap_news_link
|
|
wrapped = ("http://www.bing.com/news/apiclick.aspx?ref=FexRss&aid=&tid=x"
|
|
"&url=https://example.com/article&c=1&mkt=es-es")
|
|
assert _unwrap_news_link(wrapped) == "https://example.com/article"
|
|
# Links normales pasan intactos
|
|
assert _unwrap_news_link("https://thedebrief.org/foo") == "https://thedebrief.org/foo"
|
|
# apiclick sin url= no revienta
|
|
assert _unwrap_news_link("http://www.bing.com/news/apiclick.aspx?ref=x") \
|
|
== "http://www.bing.com/news/apiclick.aspx?ref=x"
|