diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-02 14:05:25 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-02 14:05:25 +0900 |
| commit | 5e2d5887d1f6bc7919948e3f269cfa00e243cb9f (patch) | |
| tree | 9899e31f4bb86fca0d7f56214aa61eaf3ab3067f /services/news-collector/tests/test_truth_social.py | |
| parent | 0f1cb0fcd033aef5c1add796821348507580055b (diff) | |
feat: implement Truth Social and Federal Reserve collectors
Diffstat (limited to 'services/news-collector/tests/test_truth_social.py')
| -rw-r--r-- | services/news-collector/tests/test_truth_social.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/services/news-collector/tests/test_truth_social.py b/services/news-collector/tests/test_truth_social.py new file mode 100644 index 0000000..bcf8a8c --- /dev/null +++ b/services/news-collector/tests/test_truth_social.py @@ -0,0 +1,30 @@ +"""Tests for Truth Social collector.""" +import pytest +from unittest.mock import AsyncMock, patch +from news_collector.collectors.truth_social import TruthSocialCollector + +@pytest.fixture +def collector(): + return TruthSocialCollector() + +def test_collector_name(collector): + assert collector.name == "truth_social" + assert collector.poll_interval == 900 + +async def test_is_available(collector): + assert await collector.is_available() is True + +async def test_collect_parses_posts(collector): + mock_posts = [ + {"content": "<p>We are imposing 25% tariffs on all steel imports!</p>", "created_at": "2026-04-02T12:00:00.000Z", "url": "https://truthsocial.com/@realDonaldTrump/12345", "id": "12345"}, + ] + with patch.object(collector, "_fetch_posts", new_callable=AsyncMock, return_value=mock_posts): + items = await collector.collect() + assert len(items) == 1 + assert items[0].source == "truth_social" + assert items[0].category.value == "policy" + +async def test_collect_handles_empty(collector): + with patch.object(collector, "_fetch_posts", new_callable=AsyncMock, return_value=[]): + items = await collector.collect() + assert items == [] |
