# tests/test_fetch_rss.py
import feedparser
import fetch_rss

RSS = """<?xml version="1.0"?><rss version="2.0"><channel>
<title>Pitchfork</title>
<item><title>Radiohead announce tour</title><link>https://pitchfork.com/news/1/</link>
<guid>pf-1</guid><pubDate>Mon, 20 Jul 2026 10:00:00 GMT</pubDate>
<description>news body</description></item>
</channel></rss>"""

def test_entries_from_parsed():
    parsed = feedparser.parse(RSS)
    recs = fetch_rss.entries_from_parsed("https://pitchfork.com/rss/news/", parsed)
    assert recs[0]["title"] == "Radiohead announce tour"
    assert recs[0]["link"] == "https://pitchfork.com/news/1/"
    assert recs[0]["source"] == "pitchfork.com"
    assert recs[0]["published"].startswith("2026-07-20")
