diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-02 13:59:47 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-02 13:59:47 +0900 |
| commit | a30ab1e79f5c5318b581212528747317fc8bfb15 (patch) | |
| tree | 0388ef3fab6efe7b421ba1d34f3dbfc89b6ef813 /services/news-collector/tests/test_rss.py | |
| parent | 46db308e19bd055299e57e2f42de9787ab542af7 (diff) | |
feat: implement RSS news collector (Yahoo, Google News, MarketWatch)
Diffstat (limited to 'services/news-collector/tests/test_rss.py')
| -rw-r--r-- | services/news-collector/tests/test_rss.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/services/news-collector/tests/test_rss.py b/services/news-collector/tests/test_rss.py new file mode 100644 index 0000000..58c5f7c --- /dev/null +++ b/services/news-collector/tests/test_rss.py @@ -0,0 +1,48 @@ +"""Tests for RSS news collector.""" + +import pytest +from unittest.mock import AsyncMock, patch +from datetime import datetime, timezone + +from news_collector.collectors.rss import RSSCollector + + +@pytest.fixture +def collector(): + return RSSCollector() + + +def test_collector_name(collector): + assert collector.name == "rss" + assert collector.poll_interval == 600 + + +async def test_is_available(collector): + assert await collector.is_available() is True + + +async def test_collect_parses_feed(collector): + mock_feed = { + "entries": [ + { + "title": "NVDA surges on AI demand", + "link": "https://example.com/nvda", + "published_parsed": (2026, 4, 2, 12, 0, 0, 0, 0, 0), + "summary": "Nvidia stock jumped 5%...", + }, + { + "title": "Markets rally on jobs data", + "link": "https://example.com/market", + "published_parsed": (2026, 4, 2, 11, 0, 0, 0, 0, 0), + "summary": "The S&P 500 rose...", + }, + ], + } + + with patch.object(collector, "_fetch_feeds", new_callable=AsyncMock, return_value=[mock_feed]): + items = await collector.collect() + + assert len(items) == 2 + assert items[0].source == "rss" + assert items[0].headline == "NVDA surges on AI demand" + assert isinstance(items[0].sentiment, float) |
