Add Reddit API wrapper and related tests; update environment configuration

This commit is contained in:
2025-09-30 15:36:37 +02:00
parent c1952526ad
commit 43b2bddba5
7 changed files with 171 additions and 14 deletions

24
tests/api/test_reddit.py Normal file
View File

@@ -0,0 +1,24 @@
import pytest
from praw import Reddit
from app.social.reddit import MAX_COMMENTS, RedditWrapper
@pytest.mark.social
@pytest.mark.api
class TestRedditWrapper:
def test_initialization(self):
wrapper = RedditWrapper()
assert wrapper.client_id is not None
assert wrapper.client_secret is not None
assert isinstance(wrapper.tool, Reddit)
def test_get_top_crypto_posts(self):
wrapper = RedditWrapper()
posts = wrapper.get_top_crypto_posts(limit=2)
assert isinstance(posts, list)
assert len(posts) == 2
for post in posts:
assert post.title != ""
assert isinstance(post.comments, list)
assert len(post.comments) <= MAX_COMMENTS
for comment in post.comments:
assert comment.description != ""

View File

@@ -21,6 +21,7 @@ def pytest_configure(config:pytest.Config):
("ollama_gpt", "marks tests that use Ollama GPT model"),
("ollama_qwen", "marks tests that use Ollama Qwen model"),
("news", "marks tests that use news"),
("social", "marks tests that use social media"),
("limited", "marks tests that have limited execution due to API constraints"),
("wrapper", "marks tests for wrapper handler"),
]